Dependent Origination

How to figure out why a third-party API isn’t returning what you expect

Posted on: May 17, 2012

The third-party provides example scripts using command line curl and they work well — so you know it must be your problem. The question is how to figure out what your problem is.

Things I find useful along the way:

1. Postman Google Chrome Extension — you can search it in Chrome Web Store — very easy to use, simple and intuitive interface, really good tool to try out an HTTP API

2. Luckily our C++ code of a HTTP client can print out the raw request if you lower the debug level so I get a raw HTTP request easily. You have to figure out if using other bindings/libraries.

3. Use netcat host port < request.txt to send the host a raw http request you obtain from step 2. you can tweak your raw request here to make it work 🙂 you can use telnet host 80 and paste that request too but netcat is better if you tweak your requests.

4. Unfortunately you cannot make it work with simple tweaks. the only thing now is getting the raw request from the working third-party script  and compare to our own. Curl makes it easy: use –verbose or –trace-ascii. –verbose in fact prints out the request (sans the actual form data part) while –trace-ascii is only printing out what curl receives from the host, so it is a little different from what Curl tutorial is saying about http scripting.

5. At this point, the two raw requests compare nicely: I am sending out the wrong Content-Type header and change it. All set.

Feel really good about figuring out this myself 🙂

For reference, this page lists the basics of HTTP GET/POST nicely.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

May 2012
M T W T F S S
« Apr   Jun »
 123456
78910111213
14151617181920
21222324252627
28293031  

Twitter

  • is reflecting on the past three years and reading the article on divided self aptly showing up at the top of my tweeter feed. 3 months ago
  • is having a nice feeling of connecting dots all over the place. they are now illuminating the same point. 5 months ago
  • Style Transfer is fun! TensorFlow rocks! #WTM17 https://t.co/zYP0IFIDfp 6 months ago
  • couldn't get over the jetlag, sleeping during the day from seven to four, for days. 8 months ago
  • is emptying trash and happily discovering the available disk space now ranks at 100G+. 9 months ago

Flickr Photos

%d bloggers like this: