Skip to main content

invalid_json

HTTP Status: 400 Bad Request

Example response

What happened?

The request body could not be parsed as valid JSON. This happens when:
  • The JSON syntax is malformed (missing quotes, trailing commas, unescaped characters)
  • The request body is empty when JSON was expected
  • The body contains non-JSON content (e.g. form-encoded data)

How to fix

  1. Validate your JSON: Use a JSON linter or JSON.parse() locally before sending
  2. Set the Content-Type header: Include Content-Type: application/json
  3. Check for trailing commas: JSON does not allow trailing commas after the last element

Common mistakes

  • Trailing commas: ["a", "b",] is invalid JSON
  • Single quotes: JSON requires double quotes. {'key': 'value'} is invalid
  • Unescaped characters: Special characters in strings must be escaped
  • Empty body: Sending a POST with no body when JSON is expected

Catching this error with the SDKs