In this blog we are going to discuss 10 most important status codes that every developer should use while developing any website / web application.
1- OK ( 200 )
This response code indicates that the website is performing normal/smooth. The resource requested from the server has been fetched and transmitted successfully to the client/browser.
Example- Get the list of users.
2- Created ( 201 )
This response code indicates that the client request to create one or more number of records has been accepted and performed successfully.
Example- Create new record in users.
3- Accepted ( 202 )
This response code indicates that the server has accepted the client’s requested but the request is still under process by the server.
Example- Allocated some resource on multiple microservice when the new user register.
4- NoContent ( 204 )
This response code indicates that the clients request has been processed but there is no records on the server to send in the payload/body.
Example- Get lists of all the users whose birth year is 2050.
5- Bad Request ( 400 )
This response code indicates that the client’s request was incorrect or corrupted, And the server is unable to understand the request.
6- Unauthorized ( 401 )
This response code indicates that the client’s request for the particular website/API calls can be served only to the client with valid ID and password.
Example- Get the list of bank information associated with me without login.
7- Forbidden ( 403 )
This response code indicates that the client’s request can not be fullfilled due to some client-related issues.
Example- User A requesting the private information of User B, Here private information of user X can only be accessed by user X.
8- NotFound ( 404 )
This response code indicates that the resource the client was requesting does not exists on the server.
9- Method Not Allowed ( 405 )
This response code indicates that the route method that the client is using is not allowed on the server.
Example- Client is making the get request on path “/xyz” but the server only accepts post request on path “/xyz”
10- Internal Server Error ( 500 )
This response indicates that something wrong has happen on the server but the server could not tell the exact problem due the fact of error, or hiding inner level complexity from the client.
Example- Server take responses from 2 other servers via server to server communication, And one of the server failed/down.
If you have feedback or questions about this page, add a comment below or send message to me on LinkedIn https://www.linkedin.com/in/adeshkumarsingh/