Response status codes
Success
Successes differ from errors in that their body may not be a simple response object with a code and a message. The headers however are consistent across all calls:
GET
,PUT
,DELETE
returns200 OK
on success,POST
returns 201 on success,
When retrieving stuff for example:
Status: 200 OK
{
{
id: thing_1,
name: 'My first thing'
},
{
id: thing_2,
name: 'My second thing'
}
}
Error
Error responses are simply returning standard HTTP error codes along with some additional information:
- The error code is sent back as a status header,
- The body includes an object describing both the code and message (for debugging and/or display purposes),
For a call with an invalid authentication token for example:
Status: 401 Access denied
{
code: 401,
message: 'Access denied: invalid authentication token.'
}