Skip to content
400

Bad Request

Client Error (4xx)

The 400 Bad Request status code indicates that the server cannot process the request due to something perceived as a client error. This could be malformed syntax, invalid request framing, or deceptive request routing. It is a generic client error response used when no other 4xx code is more specific. The response body should include details about what was wrong with the request.

What is HTTP 400 Bad Request?

HTTP 400 Bad Request is a client error (4xx) status code. The 400 Bad Request status code indicates that the server cannot process the request due to something perceived as a client error. This could be malformed syntax, invalid request framing, or deceptive request routing. It is a generic client error response used when no other 4xx code is more specific. The response body should include details about what was wrong with the request. Common causes include malformed json or xml in request body and missing required request parameters. To fix it, check the request body for valid json/xml syntax.

Example Response

HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error": "Invalid JSON", "details": "Unexpected token at position 42"}

Common Causes

How to Fix

  1. 1. Check the request body for valid JSON/XML syntax
  2. 2. Verify all required parameters are included
  3. 3. Ensure Content-Type header matches the body format
  4. 4. Check for special characters that need URL encoding
  5. 5. Review API documentation for the correct request format

Frequently Asked Questions

How do I debug a 400 Bad Request?

Check the response body for error details. Common issues include malformed JSON, missing required fields, and incorrect Content-Type headers. Use a tool like Postman or curl to inspect the exact request being sent.

Should my API return 400 or 422 for validation errors?

400 is for syntactically incorrect requests (bad JSON). 422 Unprocessable Entity is more specific for semantically invalid data (valid JSON but fails business rules). Both are acceptable, but 422 provides more precision.

Can a 400 error be caused by the server?

By definition, 400 means the client made an error. However, a misconfigured server might return 400 incorrectly. If you are confident your request is correct, the issue may be server-side.

Related Status Codes

401 Unauthorized 403 Forbidden 404 Not Found 415 Unsupported Media Type

Related Reading

HTTP Status Codes Cheat Sheet: Every Code Explained → JSON vs YAML vs TOML: Which Config Format to Use →