RFC 2616 defines a set of status codes set when the RESTful web service responds to a REST request. The status code gives the client making the request a quick idea of the request's success or failure. The default response in most situations is status code 200, which simply means OK. More details on expected responses depend on the nature of the request (addressed in the next sub-section). Here is a brief summary of the family of status codes:
Code family | General nature |
1xx | Informational |
2xx | Success |
3xx | Redirect |
4xx | Client error |
5xx | Server error |
In cases where the RESTful web service you are defining needs to perform a redirect, it's a good idea to set a status code of either 301 (moved permanently) or 307 (temporary redirect), depending on the nature of the redirect.
Use the 4xx family of status codes in situations where the request is bad for some reason. If the requester is not authenticated or authorized, you can set status code 401...