Geeks With Blogs

News This is the *old* blog. The new one is at
Elton Stoneman
This is the *old* blog. The new one is at

Who’s bad?

The original release of was a bit limited – you could get whatever error response you needed, but only if you changed your client to point to the URLs – so if you want to test that your client behaves differently when it gets a 500 from the server, you had to change the code to point to

With the new release (from commit 6ab647e), now has dedicated host names for the common error responses, and they can take any URL. So now you can test your client in error situations without changing code, just by using a proxy and redirecting your API call to

Redirecting traffic  - simple version

If you’re working within a local network, you can install Charles, the web debugging proxy, and do the redirects from there. From the Structure window in Charles, find the base URL for your API, and select Map Remote:


Now you can map all calls for you API to at the domain level, so any resource request goes to and gets a known error response:

image ignores the rest of the URL, so you can use one redirect for all your API calls. In this example, I’ve mapped to, so all these calls will get a 503 Service Unavailable response:

  • GET
  • HEAD
  • GET
  • POST
  • PUT

Any devices on the same network where you’re running Charles can use your proxy, so you can point web browsers and tablets to the proxy machine and test their behaviour.

Redirecting traffic  - more complicated version

If you don’t want to permanently run Charles on a machine, or you need to have a proxy that can span multiple networks, you need to do a bit more.

You can create a cloud VM somewhere and use that as your proxy server – or as your DNS server.

On that server you can set up a proxy or just rig the DNS so your API hosts get repointed to the hosts.

Domain redirects has 7 hosts you can redirect to, to get known error responses:

Host Response 404: NotFound 401: Unauthorized 503: Service Unavailable 400: Bad Request 409: Conflict 500: Internal Server Error 403: Forbidden

And all those endpoints support GET, HEAD, POST, PUT and DELETE.

Full details in the live documentation: http://badapi.local/Help.

Posted on Friday, September 12, 2014 7:12 AM | Back to top

Related Posts on Geeks With Blogs Matching Categories

Comments on this post: just got badder

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Elton Stoneman | Powered by: