what is the difference between 201 and 204
CodePudding user response:
In practice, there isn't a lot of difference between a 200 with no content, a 201 and a 204: they all generically mean that the request succeeded:
a 200 response is the generic OK, and may or may not have a body attached;
a 201 response is for when the request specifically creates something and does not have a response body; and
a 204 response is for when the request succeeds but has no body to return.
CodePudding user response:
200: OK Return an entity describing or containing the result of the action - when an object is created and returned (typically JSON for REST endpoint).
If all is OK, but there is no data to return the code is 204 No Content.
201: CREATED. The request has been fulfilled and resulted in a new resource being created. - when an object is created but only its reference is returned (such as an ID or a link)