Skip to content

Invalid JSON

HTTP 400invalid_json

When the API answers 400 invalid_json, and how to fix it.

Version v1.1, updated

The type field of every invalid_json response links to this page.

On this page

The body is not valid JSON, so BIRP could not read it. Nothing was written.

At a glance

  • Status: 400 Bad Request

  • Code: invalid_json

  • Retry: No. Fix the cause first: the same request gets the same answer.

Causes and fixes

Likely cause

How to fix it

The body was written by hand, with a trailing comma, single quotes or a comment.

Build the body with the JSON functions of your language, as the examples do.

A text value holds a quote or a line break that is not escaped.

Let the JSON functions of your language escape the values.

Example

400 invalid_jsonJSON
{
  "code": "invalid_json",
  "detail": "The request body is not valid JSON.",
  "instance": "/v1/categories",
  "request_id": "a1b2c3d4-0000-4000-8000-0000000000ee",
  "status": 400,
  "title": "Invalid JSON",
  "type": "https://birp.io/developers/errors/invalid_json"
}
  • requests
  • unsupported-media-type
  • errors-overview