HTTP

HTTP 405 Method Not Allowed vs 428 Precondition Required

Both HTTP 405 (Method Not Allowed) and 428 (Precondition Required) belong to the 4xx Client Error category. 405 indicates that the HTTP method is not allowed for the requested resource. The response includes an Allow header listing valid methods. Meanwhile, 428 means that the server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.

Description

The HTTP method is not allowed for the requested resource. The response includes an Allow header listing valid methods.

When You See It

When sending POST to a read-only endpoint, or DELETE to a non-deletable resource.

How to Fix

Check the Allow response header for supported methods. Use the correct HTTP method.

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 405: The HTTP method is not allowed for the requested resource. The response includes an Allow header listing valid methods.

2.

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

3.

You encounter 405 when when sending POST to a read-only endpoint, or DELETE to a non-deletable resource.

4.

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

When to Use Which

For 405 (Method Not Allowed): Check the Allow response header for supported methods. Use the correct HTTP method. For 428 (Precondition Required): Fetch the resource first to get its ETag, then include If-Match in your update request.

Learn More