A good understanding of the HTTP protocol is crucial for a successful RESTful implementation. Although I know that REST is not dependent of HTTP, we all know that it’s the most common implementation.
Below I made a quick overview of HTTP status codes and the intent is to help during the development and test of REST services.
General HTTP Codes
1xx – Informational: Request received, continuing process.
2xx – Success: Action successfully received, understood, and accepted.
3xx – Redirection: Client must take additional action to complete the request.
4xx – Client Error: Request contains bad syntax or cannot be fulfilled.
5xx – Server Error: Server failed to fulfil an apparently valid request.
In the table below you have the description of the most common response codes:
Code Meaning Description 200
– Successful HTTP request.
– New resource created.
– Accepted for processing, but not yet completed.
– Successfully processed, but no return content.
– Only part of the resource returned.
– Multiple options for the resource that the client may follow.
– This and all future requests should be directed to the given URI.
– Response can be found at URI using GET method.
– Resource has not been modified since last requested
Method Not Allowed
Unsupported Media Type
I’m a teapot
– Request contains bad syntax or cannot be fulfilled.- Request refused, when authentication is possible but has failed or not yet been provided.
– Request was legal, but the server refuses to respond to it.
– Resource could not be found but may be available again in the future.
– Request made using method not supported by that resource.
– Resource can only generate content not acceptable given Accept headers sent in.
– Request could not be processed due to conflict in the request.
– Resource no longer available and will not be available again.
– Server does not meet precondition put on the request.
– Request did not specify any media types the resource supports.
– Server cannot meet requirement of Expect header field.
– Response entity “MAY be short and stout”.