What HTTP status response code should I use if the request is missing a required parameter?

I am thinking 412 (Precondition Failed) but there may be a better standard? 9 Answers 9 Status 422 seems most appropiate based on the spec. The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of … Read more

REST HTTP status codes for failed validation or invalid duplicate

I am building an application with a REST-based API and have come to the point where I am specifying status codes for each requests. What status code should i send for requests failing validation or where a request is trying to add a duplicate in my database? I’ve looked through http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html but none of them … Read more

HTTP response code for POST when resource already exists

I’m building a server that allows clients to store objects. Those objects are fully constructed at client side, complete with object IDs that are permanent for the whole lifetime of the object. I have defined the API so that clients can create or modify objects using PUT: PUT /objects/{id} HTTP/1.1 … {json representation of the … Read more

403 Forbidden vs 401 Unauthorized HTTP responses

For a web page that exists, but for which a user does not have sufficient privileges (they are not logged in or do not belong to the proper user group), what is the proper HTTP response to serve? 401 Unauthorized? 403 Forbidden? Something else? What I’ve read on each so far isn’t very clear on … Read more