HTTP

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

1.

HTTP 422: The server understands the content type and syntax, but was unable to process the contained instructions. Common in API validation errors.

2.

HTTP 428: The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.

3.

You encounter 422 when when form validation fails — correct syntax but invalid data (e.g., email format wrong, date in the past).

4.

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.

Learn More