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

  1. Read the response body first — most frameworks return field-level validation details.
  2. Validate your JSON payload (a strict validator pinpoints line/column) and confirm Content-Type: application/json.
  3. Reproduce with curl, then diff against the working request — header by header, byte by byte.
  4. If it only breaks in a browser, cookies are suspects: clear the site's cookies and retry.

Easily confused with