HTTP 400 Bad Request vs 422 Unprocessable Content
Both HTTP 400 (Bad Request) and 422 (Unprocessable Content) belong to the 4xx Client Error category. 400 indicates that the server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing. Meanwhile, 422 means that the server understands the content type and syntax, but was unable to process the contained instructions. Common in API validation errors.
Description
The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
When You See It
When sending malformed JSON, missing required fields, or invalid query parameters.
How to Fix
Check the request body format, validate all required fields, and ensure proper encoding.
Description
The server understands the content type and syntax, but was unable to process the contained instructions. Common in API validation errors.
When You See It
When form validation fails — correct syntax but invalid data (e.g., email format wrong, date in the past).
How to Fix
Check the response body for specific validation errors and correct the input data.
Key Differences
HTTP 400: The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
HTTP 422: The server understands the content type and syntax, but was unable to process the contained instructions. Common in API validation errors.
You encounter 400 when when sending malformed JSON, missing required fields, or invalid query parameters.
You encounter 422 when when form validation fails — correct syntax but invalid data (e.g., email format wrong, date in the past).
When to Use Which
For 400 (Bad Request): Check the request body format, validate all required fields, and ensure proper encoding. For 422 (Unprocessable Content): Check the response body for specific validation errors and correct the input data.