400 vs 411 vs 413 vs 422 Request Errors
Use these 4xx codes to separate invalid syntax, missing request length, oversized bodies, and well-formed requests that fail business validation.
Status codes in this guide
- 400 Bad Request
- 411 Length Required
- 413 Payload Too Large (RFC 7231)
- 422 Unprocessable Entity (WebDAV; RFC 4918)
Quick comparison
| Code | Main problem | First fix |
| 400 | The request is malformed or cannot be parsed. | Fix syntax, headers, routing, or body shape. |
| 411 | The server requires Content-Length before reading the body. | Send Content-Length or use a supported upload method. |
| 413 | The request body is larger than the server accepts. | Reduce the payload or raise documented limits safely. |
| 422 | The request parses correctly but fails semantic validation. | Change the submitted values according to field-level errors. |
Questions
Should invalid JSON be 400 or 422?
Invalid JSON should usually be 400 because the server cannot parse the request body.
Should a valid JSON body with invalid field values be 422?
Use 422 when the server understood the JSON but business rules or validation constraints rejected the values.
Is 413 the same as 422?
No. 413 is about body size. 422 is about a well-formed body that cannot be processed semantically.