Skip to content

HTTP status codes for REST

May 14, 2012

While developing the upcoming Essential REST course for DevelopMentor, I thought it would be useful to put together a chart illustrating the common HTTP status codes used for each of the common HTTP methods. This isn’t exhaustive and many of the status codes below might be issued by the infrastructure and not directly by your application code, but I think this is useful in keeping in mind the sorts of things your code might need to return.

method status phrase request headers response headers content in response note
GET 200 OK ETag Yes
304 Not Modified If-None-Match ETag resource has not changed since read
401 Unauthorized WWW-Authenticate
404 Not Found
405 Method Not Allowed Allow:GET, …
406 Not Acceptable Accept server doesn’t have the content type requested
410 Gone was here but not anymore
500 Server Error
503 Service Unavailable request can be retried later
POST 201 Created Location, ETag Optional
400 Bad Request e.g. validation error
401 Unauthorized WWW-Authenticate
405 Method Not Allowed Allow:GET, …
415 Unsupported Media Type Content-Type server doesn’t support that content type
500 Server Error
503 Service Unavailable request can be retried later
PUT 200 OK ETag Yes
204 No Content ETag
400 Bad Request e.g. validation error
401 Unauthorized WWW-Authenticate
404 Not Found
405 Method Not Allowed Allow:GET, …
409 Conflict can’t update due to state of resource
412 Precondition Failed If-Match ETag resource has changed since read
415 Unsupported Media Type Content-Type server doesn’t support that content type
500 Server Error
503 Service Unavailable request can be retried later
DELETE 204 No Content
401 Unauthorized WWW-Authenticate
404 Not Found
405 Method Not Allowed Allow:GET, …
412 Precondition Failed If-Match resource has changed since read
409 Conflict can’t update due to state of resource
500 Server Error
503 Service Unavailable request can be retried later

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: