Bad Request
ActiveHTTP 400 Bad Request indicates the server cannot process the request due to something perceived as a client error. Defined in RFC 9110 §15.5.1. Common causes include malformed syntax, invalid request framing, or deceptive request routing.
Description
The 400 Bad Request status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
This is a generic client error response used when no other 4xx code is applicable. The server SHOULD include a representation describing the error and potential remediation.
Examples
POST /api/users HTTP/1.1
Host: api.example.com
Content-Type: application/json
{"name": "Alice", "email": }HTTP/1.1 400 Bad Request
Content-Type: application/json
{"error": "invalid_json", "message": "Unexpected token } at position 34"}Edge Cases
- •400 is often overused as a catch-all. Consider 422 for semantically invalid but syntactically correct requests.
- •Some servers return 400 for oversized headers (should be 431).
- •CORS preflight failures may appear as 400 errors to the client.
When You'll See This
- →Malformed JSON or XML in request body
- →Missing required query parameters
- →Invalid Content-Type
- →Request header too large or malformed
Implementation References
| Language | Constant |
|---|---|
| Go | http.StatusBadRequest |
| Rust | http::StatusCode::BAD_REQUEST |
| Python | http.HTTPStatus.BAD_REQUEST |
| Node.js | http.STATUS_CODES[400] |
| .NET | HttpStatusCode.BadRequest |
| Java | HttpURLConnection.HTTP_BAD_REQUEST |
History
Present since HTTP/1.0 (RFC 1945, 1996). Remains the default client error when no more specific 4xx code applies.
Related Status Codes
Related Headers
FAQ
What causes a 400 Bad Request?
Malformed JSON/XML, missing required fields, invalid URL encoding, oversized headers, or sending the wrong Content-Type.
What is the difference between 400 and 422?
400 means the request is malformed (can't be parsed). 422 means it's syntactically valid but semantically wrong (e.g., email field contains a number).