I'm working on a project at the moment with an API, so I usually talk to it with curl. I also love Charles Proxy, a very handy tool that I use to inspect, repeat and edit requests. Today I used them together!
Curl via Charles
There might be a better way to do this as it does seem rather hacky, but here's my approach:
- Make your web request to http://localhost:8888 with whatever path/query string/verb/post data/whatever that you would normally include
- Add a Host: header
Were you expecting more to it? Sorry :)
So to make a curl request to http://api.joind.in/v2.1/events via Charles, I do this:
curl -H "Host: api.joind.in" http://localhost:8888/v2.1/events
You'll see in the overview that Charles then sends the request over to the expected URL. Useful? Hacky? Comments box is below ....