400 Bad Request
The server could not even process the request as sent — malformed JSON, invalid parameters, broken encoding, or a violated contract. It is the generic 'your request is wrong' code, and quality APIs say what exactly was wrong in the body.
What usually causes it
- Malformed JSON body (trailing comma, single quotes, truncation)
- Missing/invalid query parameters or headers
- Wrong Content-Type (sending JSON with a form content type)
- Oversized or malformed cookies (some servers use 400 instead of 431)
How to debug and fix it
- Read the response body first — most frameworks return field-level validation details.
- Validate your JSON payload (a strict validator pinpoints line/column) and confirm Content-Type: application/json.
- Reproduce with curl, then diff against the working request — header by header, byte by byte.
- If it only breaks in a browser, cookies are suspects: clear the site's cookies and retry.
Easily confused with
Debugging an API? Build and inspect requests, check response headers, or read the full status-code debugging guide.