Skip to content

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

  1. GET the resource first, then repeat the update with If-Match set to the ETag you received.
  2. Check the API docs for which conditional header it expects.

Headers that go with it

  • ETag
  • If-Match

Example response

HTTP/1.1 428 Precondition Required
ETag: "33a64df5"
Content-Type: text/plain; charset=utf-8

428 Precondition Required

How 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.

  • 412

    Precondition Failed

    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

    Conflict

    The request conflicts with the current state of the resource, such as saving a version that someone else already changed.

  • 304

    Not Modified

    The cached copy is still valid, so the server sends no body and the client loads the resource from its own cache.

← all 63 HTTP status codes

Type to search posts, tools and projects.

Keyboard shortcuts

Search+Kor/
Go to homegthenh
Go to bloggthenb
Go to projectsgthenp
Go to timelinegthent
Show this help?
Close search or helpesc