DEV Community

Cover image for How to deal with client HTTP status messages
Joyce Lin for Postman

Posted on

3 1

How to deal with client HTTP status messages

When you’re talking to an HTTP API, the server returns a status code signaling the status of your API request. Since status codes and error messages are determined by the API provider, they are only as meaningful and accurate as the API provider makes them. But most API providers follow the established industry standards grouping HTTP status codes into five categories according to the following scenarios:

  • 100s Informational responses
  • 200s Successful responses
  • 300s Redirects
  • 400s Client errors
  • 500s Server errors

Let’s dive into status codes in the 400s indicating an issue with the client. As an API consumer, this means that you can update the API call to potentially solve the issue. Assuming the server returns reliable status messages, this is our first clue to tracking down the source of the bug.

Common client error codes

Here are some common client error codes in the 400s and what you can do when you encounter one of these errors:

  • 400 Bad Request - This is the most general, catch-all status code for client errors. Look for syntax errors like typos or a malformed JSON body in your API call.
  • 401 Unauthorized - Verify that you have valid authentication credentials for the target resource and check your syntax for header values
  • 403 Forbidden - This means you do not have permission to access the resource. Check your permissions and scope to ensure you are authorized to access the resource.
  • 418 I’m a Teapot - was created as an April Fool’s joke, but may indicate the request is one the provider does not want to handle, such as automated queries
  • 429 Too Many Requests - check the documentation to understand the rate limits, or give it a break to try again later

404 error code in Postman

There’s a number of other client errors defined in the industry standard, but it’s up to the API provider to implement status messages. If you’re unable to resolve the issue, check the API documentation for more clues as to how the provider has intended to handle those requests.

And if you want to try an interactive tutorial, check out Learn HTTP Status Codes with HTTP Cats 😺.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

Billboard image

Stick around with the Forem app — the best way to keep up with DEV and other tech communities.

AI is changing our lives. Navigate the change with community

Okay