Understanding API Errors 🤖🔥: A Comprehensive Guide to HTTP Status Codes

Understanding API Errors: A Comprehensive Guide to Common HTTP Status Codes and Their Descriptions”

Ravi Tiwari
7 min readApr 10, 2023
Error Codes

APIs (Application Programming Interfaces) have become an essential part of modern software development. They allow different software systems to communicate with each other and exchange data. However, just like any other software component, APIs can sometimes fail to function as intended, leading to API errors. These errors can cause frustration for developers and users alike, which is why it’s important to understand them and know how to handle them.

In this article, we will discuss the common API errors, their descriptions.

Informational

  • 100 Continue: Indicates that the initial part of the request has been received and the client should proceed to send the remainder of the request.
  • 101 Switching Protocols: Indicates that the server is switching protocols according to the client request.
  • 102 Processing: Indicates that the server has received and is processing the request, but has not yet completed the response.
  • 103 Early Hints: Indicates that the server is sending some hints to the client about the response before the final response headers are sent.

Success

  • 200 OK: Indicates that the request was successful and the response includes the requested data or action.
  • 201 Created: Indicates that a new resource has been successfully created, and the response includes a representation of the new resource.
  • 202 Accepted: Indicates that the request has been accepted for processing, but the processing has not been completed.
  • 203 Non-Authoritative Information: Indicates that the server is returning a representation of the resource that is not from the original source, but is still accurate.
  • 204 No Content: Indicates that the request was successful, but there is no content to return. This is often used for DELETE requests where the resource has been successfully deleted.
  • 205 Reset Content: Indicates that the server is instructing the client to reset the document view, but there is no content to return.
  • 206 Partial Content: Indicates that the server is delivering only part of the resource due to a range header sent by the client.
  • 207 Multi-Status: Indicates multiple status codes for a single response during a Web Distributed Authoring and Versioning (WebDAV) operation.
  • 208 Already Reported: Indicates that the members of a WebDAV binding have already been enumerated in a preceding part of the multistatus response, and are not being included again.
  • 226 IM Used: Indicates that the server has completed a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.

Redirection

  • 300 Multiple Choices: Indicates that the requested resource has multiple representations, each with its own specific location, and the client should choose the most appropriate representation based on the context.
  • 301 Moved Permanently: Indicates that the requested resource has been permanently moved to a new location, and the client should update its bookmarks and links to the new URL.
  • 302 Found: Indicates that the requested resource has been temporarily moved to a new location, and the client should continue to use the original URL for future requests.
  • 303 See Other: Indicates that the response to the request can be found at a different URI, and the client should redirect to that URI.
  • 304 Not Modified: Indicates that the requested resource has not been modified since the last time the client accessed it, and the client should use its cached version of the resource.
  • 305 Use Proxy: Indicates that the requested resource must be accessed through a proxy, and the client should use the specified proxy server to access the resource.
  • 306 Switch Proxy (Unused): Originally used to indicate that subsequent requests should use a specified proxy, but is now unused and has been removed from the HTTP/1.1 specification.
  • 307 Temporary Redirect: Indicates that the requested resource has been temporarily moved to a new location, and the client should continue to use the original URL for future requests.
  • 308 Permanent Redirect: Indicates that the requested resource has been permanently moved to a new location, and the client should update its bookmarks and links to the new URL.

Client Errors

  • 400 Bad Request: Indicates that the server was unable to understand the request due to invalid syntax or a malformed request.
  • 401 Unauthorized: Indicates that the client must authenticate itself to get the requested response.
  • 402 Payment Required: Reserved for future use.
  • 403 Forbidden: Indicates that the server understood the request, but refuses to authorize it.
  • 404 Not Found: Indicates that the server was unable to find the requested resource.
  • 405 Method Not Allowed: Indicates that the request method (GET, POST, etc.) is not supported for the requested resource.
  • 406 Not Acceptable: Indicates that the server cannot produce a response matching the list of acceptable values defined in the request’s headers.
  • 407 Proxy Authentication Required: Indicates that the client must first authenticate itself with the proxy.
  • 408 Request Timeout: Indicates that the server timed out waiting for the request.
  • 409 Conflict: Indicates that the request could not be completed due to a conflict with the current state of the resource.
  • 410 Gone: Indicates that the requested resource is no longer available and will not be available again.
  • 411 Length Required: Indicates that the server requires a Content-Length header to be included in the request.
  • 412 Precondition Failed: Indicates that one or more preconditions given in the request header fields evaluated to false.
  • 413 Payload Too Large: Indicates that the request entity is larger than the server is willing or able to process.
  • 414 URI Too Long: Indicates that the URI provided in the request is too long for the server to process.
  • 415 Unsupported Media Type: Indicates that the server cannot process the request because the media type is not supported.
  • 416 Range Not Satisfiable: Indicates that the server cannot provide the requested range of the resource.
  • 417 Expectation Failed: Indicates that the server was unable to meet the expectations given in the request’s Expect header field.
  • 418 I’m a teapot: A humorous code indicating that the server refuses to brew coffee because it is a teapot.
  • 421 Misdirected Request: Indicates that the request was directed at a server that is not able to produce a response.
  • 422 Unprocessable Entity: Indicates that the server was unable to process the request due to invalid or unprocessable input data.
  • 423 Locked: Indicates that the resource that is being accessed is locked.
  • 424 Failed Dependency: Indicates that the request failed because it depended on another request that failed or was not completed.
  • 425 Too Early: Indicates that the server is unwilling to risk processing a request that might be replayed.
  • 426 Upgrade Required: Indicates that the client should switch to a different protocol, such as TLS/1.0.
  • 428 Precondition Required: Indicates that the server requires the request to be conditional.
  • 429 Too Many Requests: Indicates that the client has exceeded the rate limit or quota set by the server for a particular API endpoint.
  • 431 Request Header Fields Too Large: Indicates that the request headers exceed the server’s limit.
  • 451 Unavailable For Legal Reasons: Indicates that the server is refusing to respond to the request because the user has been blocked due to legal reasons.

Server Errors

  • 500 Internal Server Error: Indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
  • 501 Not Implemented: Indicates that the server does not support the functionality required to fulfill the request.
  • 502 Bad Gateway: Indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
  • 503 Service Unavailable: Indicates that the server is currently unable to handle the request due to temporary overload or maintenance of the server.
  • 504 Gateway Timeout: Indicates that the server, while acting as a gateway or proxy, did not receive a timely response from the upstream server it accessed in attempting to fulfill the request.
  • 505 HTTP Version Not Supported: Indicates that the server does not support or refuses to support the HTTP protocol version used in the request message.
  • 506 Variant Also Negotiates: Indicates that the server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper endpoint in the negotiation process.
  • 507 Insufficient Storage: Indicates that the server is unable to store the representation needed to complete the request.
  • 508 Loop Detected: Indicates that the server detected an infinite loop while processing the request.
  • 510 Not Extended: Indicates that further extensions to the request are required for the server to fulfill it.
  • 511 Network Authentication Required: Indicates that the client needs to authenticate to gain network access.

In conclusion, HTTP status codes play an important role in API development and are used to indicate the status of a request/response cycle. Developers must understand the meaning of different status codes and handle them appropriately to provide meaningful feedback to users. The 1xx informational status codes are handled by the HTTP protocol and are typically not used as common API errors. The 2xx success status codes indicate that the request was successful, while the 3xx redirection status codes indicate that the client should take additional actions to obtain the requested resource. The 4xx client error status codes indicate that there was an error with the request, while the 5xx server error status codes indicate that there was an error on the server side. Overall, developers should understand the meaning of different status codes and handle them appropriately to provide the best possible user experience for their API users.

--

--

Ravi Tiwari

Experienced hands-on CTO with 20+ years of cloud native microservices expertise, driving solutions for large-scale enterprises.