Scenario:
A POST request is sent to process an order that will result in data retrieval from an external datasource.
There are
200: OK/201: CREATED
Because everything is working as expected
400: BAD REQUEST
The request was invalid or cannot be otherwise served. An accompanying error message will explain further inside the body.like:
HTTP 400
{
response: null,
code: "USER_101", //should be used customized error codes here
error: "User details not found"
}
404: Resource/URI NOT FOUND
The URI requested or resource is invalid
Like: https://www.lipsum.com/list-page
**/list-page** is not defined/found
Find here most frequently used status codes:
200 – OK Everything is working, The resource has been fetched and is transmitted in the message body. 201 – CREATED A new resource has been created 204 – NO CONTENT The resource was successfully deleted, no response body 304 – NOT MODIFIED This is used for caching purposes. It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response. 400 – BAD REQUEST The request was invalid or cannot be served. The exact error should be explained in the error payload. 401 – UNAUTHORIZED The request requires user authentication. 403 – FORBIDDEN The server understood the request but is refusing it or the access is not allowed. 404 – NOT FOUND There is no resource behind the URI. 500 – INTERNAL SERVER ERROR API If an error occurs in the global catch blog, the stack trace should be logged and not returned as a response.