HTTP 422 Unprocessable Content vs 428 Precondition Required
Both HTTP 422 (Unprocessable Content) and 428 (Precondition Required) belong to the 4xx Client Error category. 422 indicates that the server understands the content type and syntax, but was unable to process the contained instructions. Common in API validation errors. Meanwhile, 428 means that the server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.
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.
Description
The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.
When You See It
When an API requires optimistic concurrency control via ETags.
How to Fix
Fetch the resource first to get its ETag, then include If-Match in your update request.
Key Differences
HTTP 422: The server understands the content type and syntax, but was unable to process the contained instructions. Common in API validation errors.
HTTP 428: The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.
You encounter 422 when when form validation fails — correct syntax but invalid data (e.g., email format wrong, date in the past).
You encounter 428 when when an API requires optimistic concurrency control via ETags.
When to Use Which
For 422 (Unprocessable Content): Check the response body for specific validation errors and correct the input data. For 428 (Precondition Required): Fetch the resource first to get its ETag, then include If-Match in your update request.