4xx
428 Precondition Required
The server requires the request to include conditional headers.
What is HTTP 428?
This status code indicates that the server requires the request to be conditional, meaning it must include headers like If-Match or If-Unmodified-Since. This is used to prevent the 'lost update' problem, where a client overwrites changes made by another client because it did not check the current state first. The server enforces conditional requests to ensure safe concurrent modifications.
Defined in RFC 6585
Common Causes
- A PUT or PATCH request was sent without If-Match or If-Unmodified-Since headers on a resource requiring them
- The server enforces optimistic concurrency control and requires version checking
- An API endpoint mandates conditional requests to prevent accidental data overwrites
How to Fix
- Fetch the resource first to get its current ETag or Last-Modified date
- Include an If-Match header with the resource's ETag in your update request
- Add If-Unmodified-Since with the resource's Last-Modified timestamp
- Implement proper optimistic concurrency in your client by always checking before writing