Back to httpstatuses.net

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

Quick comparison

CodeMain problemFirst fix
400The request is malformed or cannot be parsed.Fix syntax, headers, routing, or body shape.
411The server requires Content-Length before reading the body.Send Content-Length or use a supported upload method.
413The request body is larger than the server accepts.Reduce the payload or raise documented limits safely.
422The 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.


HTTP status code lookup
By Ping Now, a website/API/service uptime monitor
Data from Wikipedia