By default Web API is going to return Status Code 204 No content. We got 204 No content; that’s because the return type of the POST method is Void. The status member represents the HTTP status code associated with the problem. CreatedAtRoute will return a status code 201, which stands for Created as explained in our post: The HTTP Reference.Also, it will populate the body of the response with the new owner object as well as the Location attribute within the response header with the address to retrieve that owner. The request can be retried, though care should be taken to consider the new state of the resource to avoid blind overwriting of other agent's changes. This is a list of Hypertext Transfer Protocol (HTTP) response status codes. How many status codes should you use for your API? *.update or storage.

Therefore, most API providers use a small subset. It is also passed the text status of the response. When possible, though, the most specific status code should be … This message is distinctly different from the 404 Not Found code that we looked at a while back. Always use the appropriate HTTP action in your Web API actions, as it establishes the kinds of communication your consumers can conduct with your app. As of jQuery 1.5, the success callback function is also passed a "jqXHR" object (in jQuery 1.4, it was passed the XMLHttpRequest object).. Further, always explicitly state what HTTP method (s) each action can accept, and keep to the common definitions for each action (e.g.

It allows developers to catch groups of exceptions and not differentiate the status code that should be returned. As you can see in the above figure, the Web API controller returns HttpResponseMessage object. According to the standards of REST when we add a new item we should be actually returning status code 201 item created and along with status code 204.

414 URI Too Long is a common status code, denoting that the data pushed through in a GET request is too long, and should be converted to a POST request. You can also create and return an object of HttpResponseMessage directly from an action method.

The advantage of sending HttpResponseMessage from an action method is that you can configure a response your way. Another common code is 429 Too many Requests , which is used for rate limiting to note a client is attempting too many requests at once, and that their traffic is being rejected. It includes codes from IETF Request for Comments (RFCs), other specifications, and some additional codes used in some common applications of the HTTP.

We need to provide the name of the action, where we can retrieve the created entity: It’s very helpful when multiple errors are returned at once (see below), as the HTTP response itself can only have one status code. For example, the Google GData API uses only 10 status codes, Netflix uses 9, and Digg, only 8. Reason Description; conflict: A request to change a resource, usually a storage. *.patch method, failed to commit the change due to a conflicting concurrent change to the same resource. Note: Apigee Edge organizations can be configured to return an HTTP status code of 429 (Too Many Requests) instead of 500 for all requests that exceed a rate limit set by some rate-limiting policies. For more information, see Spike Arrest policy and Quota policy . The 405 Method Not Allowed is an HTTP response status code indicating that the specified request HTTP method was received and recognized by the server, but the server has rejected that particular method for the requested resource. Most implementations will specify a success handler: Status codes are issued by a server in response to a client's request made to the server.