428 Precondition Required
The server requires a conditional request, such as one with If-Match, to stop clients from overwriting each other's changes.
What 428 Precondition Required means
Defined in RFC 6585. An API returns 428 when a client tries to change a resource without proving it has the latest version. The client should fetch the resource, read its ETag and send it back in If-Match.
428 means the condition is missing. 412 means the condition was sent but did not match.
Common causes
- A PUT, PATCH or DELETE sent without If-Match or If-Unmodified-Since.
- A client library or proxy that drops conditional headers.
How to fix 428 Precondition Required
- GET the resource first, then repeat the update with If-Match set to the ETag you received.
- Check the API docs for which conditional header it expects.
Headers that go with it
ETagIf-Match
Example response
HTTP/1.1 428 Precondition Required
ETag: "33a64df5"
Content-Type: text/plain; charset=utf-8
428 Precondition RequiredHow to check for a 428 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 428) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 428:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 428 {
fmt.Println(res.Status)
}Specification
428 Precondition Required is defined in RFC 6585, section 3.
Related status codes
- 412
A condition in the request headers, such as If-Match or If-Unmodified-Since, was false, so the server did not apply the request.
- 409
The request conflicts with the current state of the resource, such as saving a version that someone else already changed.
- 304
The cached copy is still valid, so the server sends no body and the client loads the resource from its own cache.