Navigation
What does status code 201 created means?
The 2xx (Successful) class of status code indicates that the client’s request was successfully received, understood, and accepted.
The HTTP Status Code 201 created means that the request has been fulfilled successfully and has resulted in one or more new resources being created.
The primary resource created by the request is identified by either a Location header field in the response or, if no Location field is received, by the effective request URI.
Status
201 Created
HTTP Headers
The response might include a URI in the Location header field of the HTTP headers list that refers to the newly created resource. In addition, the response payload may contain an object that has a list of resource attributes and location(s) from which the user or user agent can select the most appropriate. The media type supplied in the Content-Type header field specifies the entity format.
Lost Update Problem
The ETag response header field in the HTTP 201 response may include the current value of the entity tag for the requested variation that was just created. To avoid the “lost update” problem, the ETag header information can be utilized in later conditional requests.
When many persons modify a resource without being aware of each other’s modifications, a lost update problem occurs. The last individual to change a resource “wins” in this circumstance, and prior updates are lost. ETags can be used in conjunction with the If-Match header to instruct the server whether or not to update a resource. If ETag does not match, the server sends a 412 (Precondition Failed) response to the client.
201 Code References
Rails HTTP Status Symbol | created |
Go HTTP Status Constant | http.StatusCreated |
Symfony HTTP Status Constant | Response::HTTP_CREATED |
Python2 HTTP Status Constant | httplib.CREATED |
Python3+ HTTP Status Constant | http.client.CREATED |
Python3.5+ HTTP Status Constant | http.HTTPStatus.CREATED |
Browser compatibility
Full Support
FAQs
What is a 201 code?
The HTTP Status Code 201 created means that the request has been fulfilled successfully and has resulted in one or more new resources being created.
What is the difference between 200 and 201 status code?
Both simply mean successful. By far the most common status code returned is 200. Simply said, it implies that the request was received, understood, and is now being processed. A 201 status code indicates that a request was successful and that a resource (for example, a new page) was generated as a result.
How do I return my 201 status code?
The request has been fulfilled and has resulted in one or more new resources being created. The primary resource created by the request is identified by either a Location header field in the response or, if no Location field is received, by the effective request URI.
Related Post:
HTTP Status Code 300-Multiple Choices
HTTP Status Code 204 – No Content
HTTP Status Code 203 – Non-authoritative Information
HTTP Status Code 207 Multi-Status
HTTP Status Code 208 Already Reported
HTTP Status Code 400 Bad Request
HTTP Status Code 401 Unauthorized
HTTP Status Code 403 Forbidden Error
HTTP Status Code 404 Not Found
HTTP Status Code 405 Method Not Allowed
HTTP Status Code 411 Length Required
Conclusion
I hope this article was able to help you with your doubts and queries related to HTTP status code 201 created. Still, if there are any questions you have that are unanswered, feel free to ask them in the comment section, we would be happy to assist you. Thank you.
Reference: 201 created
Kedar Dangal
Making a difference, Adding the sum.