Dec 17, 2024

Invalid JSON

Some common syntax errors that cause this response are missing comma, extra trailing comma, incorrect quotation marks, mismatched brackets, and encoding issues.

This error indicates that the request has content type application/json, but the request body could not be parsed as JSON.

Some common syntax errors that cause this response are:

Missing Comma

{% code-block language="json" %}
{
"name": "John"
"age": 30
}
{% end-code-block %}

There should be a comma between the two key-value pairs.

Extra Trailing Comma

{% code-block language="json" %}
{
"name": "John"
"age": 30,
}
{% end-code-block %}

The trailing comma after the last key-value pair should be removed.

Incorrect Quotation Marks

{% code-block language="json" %}
{
'name': 'John',
"age": 30,
}
{% end-code-block %}

JSON requires double quotes (") for string values and property names, not single quotes.

Mismatched Brackets

{% code-block language="json" %}
{
"name": "John",
"age": 30,
"nicknames": [ "Johnny", "Jimbo"
}
{% end-code-block %}

The array brackets are not properly closed.

Encoding Issues

For example, sending UTF-16-encoding JSON data in the body, but using a Content-Type: application/json; charset=utf-8 header that specifies a different encoding could cause JSON data to fail parsing.