LINE Messaging API · error code

LINE error 400: The request body could not be parsed as JSON

Permanent - do not retryHTTP 400400 / 409 / 413: request body, tokens and payload

Last verified against LINE Developers - Messaging API reference (error responses)

What LINE returns
The request body could not be parsed as JSON (line: XXX, column: XXX) <detail varies>

What error 400 means

LINE's parser gave up before validation even started: "The JSON in the request body could not be parsed. The specific line and column are displayed." This is a lower-level failure than The request body has X error(s) - there, your JSON was syntactically valid and individual values broke rules; here, the bytes you sent are not valid JSON at all. The line and column in the message point at the position where parsing failed in the raw request body.

Almost every occurrence is a transport or templating bug rather than a content bug. Shell scripts with unescaped quotes in curl -d, string-concatenated JSON with a trailing comma, double-encoded bodies (a JSON string containing JSON), truncated payloads from a client timeout, and templates that interpolate user text containing " or newlines without escaping are the classics. Note the adjacent failure modes: if the body is valid JSON but the header says something other than application/json, you get The content type, XXX, is not supported; if the body is valid JSON with a bad field, you get the validation error with a details array instead.

The error is deterministic and free - nothing was delivered, no quota was consumed, and retrying the identical bytes will fail identically. Fix the serialization, not the schedule.

What it looks like

{
  "message": "The request body could not be parsed as JSON (line: 4, column: 21)"
}

Why it happens

  • User-generated text interpolated into a JSON template without escaping quotes, backslashes, or newlines.
  • Trailing commas, comments, or single quotes - legal in JavaScript objects but not in JSON.
  • Double encoding: passing an already-serialized JSON string to another json encoder or to curl with extra quoting.
  • A truncated body caused by a client-side timeout, a proxy limit, or writing the payload with the wrong content length.
  • Sending form-encoded or multipart data to an endpoint that expects a raw JSON body.

How to fix LINE error 400

  1. 1Log the raw outbound body bytes and run them through a local JSON parser - it will fail at the same line and column the error reports.
  2. 2Build payloads with your language's JSON serializer (json.dumps, JSON.stringify) instead of string concatenation or manual templates.
  3. 3In shell reproductions, pass the body via a file (curl -d @body.json) to eliminate quoting problems.
  4. 4Check for double encoding: the body should start with { or [, not with a quoted string like \"{.
  5. 5Verify no proxy or middleware rewrites or truncates the body between your service and api.line.me.

How to stop it recurring

Ban string-built JSON in code review; every Messaging API payload should pass through a real serializer and, for message objects, the free validate endpoints in CI. Escape-test your templates with hostile input ("quotes", newlines, emoji) since user text eventually contains all of them. Keep one shared HTTP client that always sets Content-Type: application/json and serializes centrally - it removes this entire error class along with content-type mismatches.

Official reference: LINE Developers - Messaging API reference (error responses). See all LINE error codes or the LINE limits and quotas.

Related codes

Error 400 - quick answers

What does LINE error 400 mean?

LINE's parser gave up before validation even started: "The JSON in the request body could not be parsed. The specific line and column are displayed." This is a lower-level failure than The request body has X error(s) - there, your JSON was syntactically valid and individual values broke rules; here, the bytes you sent are not valid JSON at all.

How do I fix LINE error 400?

1. Log the raw outbound body bytes and run them through a local JSON parser - it will fail at the same line and column the error reports. 2. Build payloads with your language's JSON serializer (json.dumps, JSON.stringify) instead of string concatenation or manual templates. 3. In shell reproductions, pass the body via a file (curl -d @body.json) to eliminate quoting problems. 4. Check for double encoding: the body should start with { or [, not with a quoted string like \"{.…

Should I retry after error 400?

No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.

Stop debugging LINE by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.