DEV Community

Cover image for HTTP response codes and Error Handling
Ajit
Ajit

Posted on • Edited on

HTTP response codes and Error Handling

The most common HTTP response codes and what to do next for each:

200 OK: This response code means the request was successful and the requested information has been returned in the response body. No further action is required.

201 Created: This response code means the request was successful and a new resource has been created. The new resource can be found in the response body.

204 No Content: This response code means the request was successful, but there is no representation to return (i.e. the response body is empty).

400 Bad Request: This response code means the request was invalid or cannot be served. The client should modify the request before retrying.

401 Unauthorized: This response code means the request requires authentication and the client has not provided valid credentials. The client should authenticate and then resend the request.

403 Forbidden: This response code means the client does not have access to the requested resource, even with valid credentials. The client should not retry the request without permission.

404 Not Found: This response code means the requested resource could not be found on the server. The client may retry the request at a later time.

429 Too Many Requests: This response code indicates that the user has sent too many requests in a given amount of time. The client should implement rate limiting in their code to handle this error and avoid sending too many requests.

500 Internal Server Error: This response code means an error occurred on the server while processing the request. The client may retry the request at a later time.

These are some of the most common HTTP response codes, but there are many others with specific meanings and next steps. It's important to have a clear understanding of these codes to effectively handle responses from an API.

Top comments (0)