HTTP

HTTP 400 Bad Request vs 409 Conflict

Both HTTP 400 (Bad Request) and 409 (Conflict) belong to the 4xx Client Error category. 400 indicates that the server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing. Meanwhile, 409 means that the request conflicts with the current state of the server. Often due to concurrent modification or business rule violations.

Description

The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.

When You See It

When sending malformed JSON, missing required fields, or invalid query parameters.

How to Fix

Check the request body format, validate all required fields, and ensure proper encoding.

Description

The request conflicts with the current state of the server. Often due to concurrent modification or business rule violations.

When You See It

When trying to create a resource that already exists, or updating a resource that was modified by another request.

How to Fix

Refresh the resource state, resolve conflicts, and retry. Use ETags for optimistic concurrency.

Key Differences

1.

HTTP 400: The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.

2.

HTTP 409: The request conflicts with the current state of the server. Often due to concurrent modification or business rule violations.

3.

You encounter 400 when when sending malformed JSON, missing required fields, or invalid query parameters.

4.

You encounter 409 when when trying to create a resource that already exists, or updating a resource that was modified by another request.

When to Use Which

For 400 (Bad Request): Check the request body format, validate all required fields, and ensure proper encoding. For 409 (Conflict): Refresh the resource state, resolve conflicts, and retry. Use ETags for optimistic concurrency.

Learn More