Here is a list of potential HTTP response status codes and some guidance/hints on how to handle each one.
Be careful not to rely on individual status codes for determining overall success/failure of a request. The success status code may change depending on the content of the response or the action taken by the server (for example, we are doing background processing of the request, or there is now a body for the response.) Because of this, it's good practice to accept any success code as a successful response. You may still implement response handlers for individual status codes but only after a success/failure check has been performed.
Success
- 200 OK
This is what we like to see: everything's fine; let's keep going. - 201 Created
You’ve just created a resource and everything's fine. This response will contain a Location header whose value will be a link to the created resource. - 202 Accepted
The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. - 204 No Content
The request was successful; though, the response will not contain a body. This status is normally returned for requests where no response body is needed -- for example, from a DELETE request or a PUT (update) request.
Error
- 400 Bad Request
You need to reformat the request and resubmit it. - 401 Not Authorized
Authentication failed, but for whatever reason, it needs to be dealt with. - 403 Forbidden
You are not authorized to access this resource. - 404 Not Found
The service is far too lazy to give us a real reason why our request failed, but whatever the reason, it needs to be dealt with. - 405 Method Not Allowed
The request wasn’t allowed. You need to set the correct HTTP method for the resource identified by the request URI. - 406 Not Acceptable
You set the request ‘Accept’ header to a media type the API doesn’t support. - 409 Conflict
You tried to update the state of a resource, but the service isn't happy about it. We'll need to get the current state of the resource (either by checking the response entity body, or doing a GET) and figure out where to go from there. - 412 Precondition Failed
The request wasn’t processed because an Etag, If-Match or similar guard header failed evaluation. - 422 Unprocessable Entity
The request wasn't processed because the data failed validation. Check the response body for details about the issue. - 429 Too Many Requests
The request wasn’t processed, too many requests have been sent within a given time period. Check the response header for details about the rate limit. - 500 Internal Server Error
The ultimate lazy response. The server's gone wrong and it's not telling why.
Other
- 301 Moved Permanently
The resource at the given URI has moved permanently. You should look to the response ‘Location’ header for the new resource URI. - 304 Not Modified
You have just performed a conditional GET (see Caching section) and the resource hasn’t been modified.
