HTTP Status 201 indicates that as a result of
HTTP POST request, one or more new resources have been successfully created on server.
The response may contain URI in
Location header field in HTTP headers list, which can have reference to the newly created resource. Also, response payload also may include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the
Content-Type header field.
202 (Accepted)response instead.
Lost update problem
HTTP 201 response MAY contain an
ETag response header field indicating the current value of the entity tag for the requested variant just created.
ETag header field can be used in later conditional requests to prevent the “lost update” problem.
Lost update problem happens when multiple people edit a resource without knowledge of each others’ changes. In this scenario, the last person to update a resource “wins”, and previous updates are lost. ETags can be used in combination with the
If-Match header to let the server decide if a resource should be updated. If
ETag does not match then server informs the client via a
412 (Precondition Failed) response.
Reference: 201 (Created)