Make Love not War

RESTful HTTP Response Codes

24 June 2011

Recently I have been building RESTful APIs in Ruby on Rails so I decided to compile a list of HTTP Status Codes to use. This is just a guideline.~

Successful Responses:

  • 200 (OK) - everything is fine
  • 201 (Created)- resource successfully created
  • 202 (Accepted) - the call returned but the request was queued up. Somewhat async behavior. Unclear how to communicate error, possibly through the resource state
  • 204 (No Content) - A successful DELETE

Unsuccessful Responses:

  • 400 (Bad Request) - the request could not be understood
  • 401 (Unauthorized Access) - need to authenticate the client
  • 404 (Not found) - the resource was not found, for requests like /resource/id
  • 415 (Unsupported Media Type) - wrong content type in either "Content-Type" header or "Accept" header
  • 422 (Un-processable Entity) - The request had right content type and the request was understood but the logic of the app prevented it from being complete
  • 500 (Server Error) - something bad happened on the server, unexpected error