HTTP

HTTP 417 Expectation Failed vs 428 Precondition Required

Both HTTP 417 (Expectation Failed) and 428 (Precondition Required) belong to the 4xx Client Error category. 417 indicates that the server cannot meet the requirements of the Expect header. 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 cannot meet the requirements of the Expect header.

When You See It

When the server doesn't support Expect: 100-continue.

How to Fix

Remove the Expect header from your request.

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 417: The server cannot meet the requirements of the Expect header.

2.

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

3.

You encounter 417 when when the server doesn't support Expect: 100-continue.

4.

You encounter 428 when when an API requires optimistic concurrency control via ETags.

When to Use Which

For 417 (Expectation Failed): Remove the Expect header from your request. For 428 (Precondition Required): Fetch the resource first to get its ETag, then include If-Match in your update request.

Learn More