HTTP 405 Method Not Allowed vs 412 Precondition Failed
Both HTTP 405 (Method Not Allowed) and 412 (Precondition Failed) 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, 412 means that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
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
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
When You See It
When using conditional requests with ETags and the resource has changed.
How to Fix
Refresh the ETag/Last-Modified value and retry with updated preconditions.
Key Differences
HTTP 405: The HTTP method is not allowed for the requested resource. The response includes an Allow header listing valid methods.
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
You encounter 405 when when sending POST to a read-only endpoint, or DELETE to a non-deletable resource.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
When to Use Which
For 405 (Method Not Allowed): Check the Allow response header for supported methods. Use the correct HTTP method. For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions.