Precondition Required — the origin server requires the request to be conditional
What 428 Means
The 428 error on the HTTP Status-Codes indicates precondition required — the origin server requires the request to be conditional. This typically occurs due to missing 'if-match' or 'if-modified-since' headers in a modifying request.
A 428 Precondition Required response is used to prevent the 'lost update' problem, where a client GETs a resource, modifies it, and PUTs it back to the server, while a third party has modified the state on the server in the meantime, leading to a conflict.
Technical Background
The 428 status is a safety feature for stateful resources. By demanding a conditional request, the server ensures that the client is aware of the current state before making changes. This is defined in RFC 6585.
This error is common in RESTful APIs that manage complex resources where concurrent edits are likely. It shifts the responsibility of conflict detection to the client, requiring it to handle potential state mismatches explicitly.
Unlike 412 Precondition Failed, which means a condition was provided but failed, 428 means the condition was missing entirely when the server's policy mandates its presence.
Common Causes
- Missing 'If-Match' or 'If-Modified-Since' headers in a modifying request
- Server policy to prevent 'lost update' problems in collaborative environments
- Strict state management requiring clients to prove they have the latest version
Typical Scenarios
- A developer tries to update a shared configuration file without providing an ETag to verify they aren't overwriting someone else's changes
- An API refuses a DELETE request because the client hasn't confirmed the resource hasn't changed since it was last fetched
What to Know
Include conditional headers like If-Match (with an ETag) or If-Modified-Since in your request. This requires fetching the resource first to obtain its current state identifier.
Frequently Asked Questions
Common questions about HTTP 428 error
The server wants you to provide a condition (like an ETag) to prove you are working with the latest version of the data before you try to change it.