HTTP API Status code tips

2xx - "Yup, that worked, probably"

200 is usually a good thing.

400 Bad Request - “I haven’t got a clue what you are asking”.

The way you formed the API URL is likely to be wrong, double check !

401 Unauthorized - "I don’t know who you are, you need to authenticate yourself"

You will need to do some form of authentication … check the API documentation

403 Forbidden - “I know who you are, but I am not letting you at that”/

In this case you have probably authenticated OK, but you don’t have permission to do what you asked. Might be worth looking at SCOPEs you have asked for ? Also check on the method (PUT, GET etc) here as well.

404 Not Found - “I can’t find the thing you are looking for” (or I can but I am not going to tell you that)

We all know this one … but in an API context you need to check the “resource” which tends to be the numbers after the words

GET http://api.stuff.com/fruit/1234567

So, in this case, the fruit with the resource id 1234567 doesn’t exist

405 Method Not Allowed - "I know what you want to do and on what, but you can’t do it that way"

Check the method in your setup, are you doing a GET when it wants a POST ?

5xx - “It’s all gone horribly wrong at our end”.

Chances are it is them not you.

10 Likes