A RESTful API should use meaningful status codes that are defined in the HTTP standard to indicate the result of a request. The following are the status codes for different scenarios, which are divided into different types:
- 2xx—Success codes:
- 200 OK: Indicates a successful GET, PUT, or PATCH request. It can also be used for a POST request that is not for creating resources, or a DELETE request when the response needs to contain the representation of a removed resource.
- 201 Created: Indicates a successful POST request or a PUT request that is for creating a new resource. Usually, a location header is also returned with the URI of the new resource.
- 204 No Content: Indicates a successful request that does not contain ...