Skip to content
Owais Khan Software Reviews
How-To Guides

Fixing the Invalid JSON Was Specified Error in API Requests and Forms

Learn why the 'invalid JSON was specified' error happens, how to identify syntax and encoding flaws, and how to format payloads properly.

By Owais Khan

The error message “invalid JSON was specified” (or {"code":"INVALID_JSON","message":"An invalid JSON was specified"}) occurs when a receiving service, endpoint, or application expects a well-formed JSON object but instead receives non-JSON data, raw HTML, unencoded parameters, or text containing unescaped control characters such as literal newlines and unsupported bullets.

To resolve it, verify that your payload passes strict syntax parsing, replace unescaped special characters with standard escape sequences, ensure all submitted form parameters containing JSON are fully percent-encoded, and confirm that the upstream server is not returning an unexpected HTML error page instead of JSON.

Core Syntax and Transmission Rules That Trigger Invalid JSON

When working with REST APIs, cloud workflows, and digital form processing tools, JSON parsing relies on specific requirements. Failure to follow these rules triggers invalid JSON rejections:

  1. Literal Newlines Are Disallowed Inside String Literals You cannot have a literal newline character inside a JSON string. Any line break inside a string value must be written using the explicit escape sequence \n. When unescaped newlines are included in form text fields or descriptions, JSON parsers crash.

  2. Special Characters and Unsupported Bullet Formatting Cause Failures Entering non-standard text formatting—such as bullet points or unsupported language symbols—into form fields, email descriptions, or cover messages frequently breaks JSON generation. Removing bullet characters or replacing complex formatting with standard plain text restores successful parsing.

  3. Form-Encoded JSON Must Be Percent-Encoded When you craft an HTTP request yourself and submit JSON data inside form parameters (such as a dedicated parameter holding raw stringified JSON), failure to percent-encode that JSON payload prevents the server from parsing the parameter as valid JSON.

  4. Non-JSON Data and HTML Responses Lead to Conversion Failures Services attempting to convert JSON data will fail if the provided input is not JSON at all. For example, if an integration expects a valid JSON string but instead receives an HTML document (such as <HTML LANG="en-US"> returned during server-level failures or misconfigurations), the conversion fails because the text parameter is not valid JSON.

  5. Server Rewrite Rules and URL Mismatches Cause Invalid Responses In web and form engines, an invalid JSON response error can occur when rewrite rules or URL misconfigurations cause an endpoint to return an error page instead of JSON. Refreshing rewrite rules (such as saving permalink configurations to rebuild server .htaccess directives) and aligning HTTP versus HTTPS protocols across site settings eliminate conflicts where endpoints fail to deliver JSON.

Reference Summary: Error Conditions, Mechanisms, and Fixes

Trigger Condition Failure Mechanism Resolution Protocol
Literal newline in string value Breaks JSON string grammar; parser encounters a raw line break Replace raw newline with the escape sequence \n
Bullet characters or customized cover text Unsupported symbols interrupt string serialization in form handlers Remove bullets and use simple, plain descriptions
Raw JSON inside HTTP form parameter Server receives unencoded characters, confusing query/body parsers Percent-encode all submitted JSON data inside form parameters
Upstream endpoint returns HTML Integration receives raw <HTML> markup rather than JSON text Check the raw response to inspect the HTML message or verify server routes
Server rewrite or URL routing mismatch Endpoint produces an HTML error page rather than a valid JSON response Resave permalinks to refresh rewrite rules; align HTTP/HTTPS site URLs

What Does Invalid JSON Mean?

Invalid JSON means that the data string provided to a parser does not conform to standard JSON grammar or cannot be parsed into an object. A parser scans character by character; if it encounters an unescaped control character, an unencoded symbol in a transport parameter, or raw HTML tags instead of an opening brace or bracket, it halts immediately. Because computers require exact structural syntax, any missing delimiter, poorly encoded character, or unexpected document format causes the entire payload to be rejected.

Why Is It Saying My Signature Is Invalid?

When sending agreements, digital signatures, or fill-and-sign requests, users frequently see validation errors or JSON crashes right after filling out the signing request details. In many document workflows, the system packages the document title, recipient lists, and message body into a JSON payload behind the scenes before dispatching the request.

If the customized subject or message body contains bullet points, unescaped quotes, or unusual special characters, the internal JSON serializer generates malformed JSON. This causes the application to reject the submission, drop the agreement progress, and report an invalid JSON or invalid signature request error. Removing bulleted lists, avoiding special character sets, or utilizing standard default cover text resolves the issue.

Practical Walkthrough: Correcting an Invalid JSON API Submission

Consider an integration sending an agreement and notification payload over an HTTP POST request.

The Problematic Input

In this scenario, a client submits a raw HTTP request where the message contains literal newlines and unescaped bullets, while sending the data directly in an unencoded form parameter:

POST /api/v1/agreements HTTP/1.1
Host: api.example.com
Content-Type: application/x-www-form-urlencoded

AgreementPayload={"name":"Service Agreement","instructions":"Please review:
• Sign section A
• Return promptly"}

This submission fails for three distinct reasons:

  1. The instructions property contains raw, literal line breaks.
  2. The bullet character (•) disrupts character parsing in strict serializers.
  3. The raw JSON structure inside AgreementPayload is not percent-encoded.

The Corrected Input

To correct the payload, replace the literal newlines with \n, replace the bullet formatting with standard numbered text, and ensure the entire JSON payload is properly percent-encoded if passed inside an HTTP form parameter:

{
 "name": "Service Agreement",
 "instructions": "Please review:\n1. Sign section A\n2. Return promptly"
}

When transmitted inside a form parameter, the value must be percent-encoded as follows:

AgreementPayload=%7B%22name%22%3A%22Service%20Agreement%22%2C%22instructions%22%3A%22Please%20review%3A%5Cn1.%20Sign%20section%20A%5Cn2.%20Return%20promptly%22%7D

To quickly inspect and clean payloads before sending them over the wire, testing your text through the JSON Formatter helps pinpoint missing escape sequences, stray quotes, or malformed braces.

Differences by Context and Platform

While invalid JSON always stems from parser rejection, the root environment dictates where the breakdown takes place:

  • REST API and Direct Client Requests: When writing custom code with HTTP clients, errors commonly arise from parameter mapping and header handling. For instance, sending stringified JSON as a named form parameter instead of properly encoding it or placing it correctly in the request body causes the server to reject the parameter with messages like error 54008 (“The specified ‘Data’ parameter is not valid JSON”).
  • Desktop and Web Sign Software: In user-facing document and signature tools, users do not write raw JSON directly. Instead, the user interface takes the form fields (email fields, agreement names, and custom cover notes) and compiles them into a JSON payload. If the description includes bullet points or non-standard characters, the client crashes or resets the process without completing the signature dispatch.
  • Integration Platforms and Process Engines: When integration engines convert responses into native platform values, an invalid JSON error typically indicates that the downstream web service returned an unexpected status page or HTML document instead of JSON. Examining the raw server response reveals whether the service received an HTML error page rather than the expected JSON structure.
  • Content Management and Form Plugins: In web publishing tools, an “invalid JSON response” during form publishing or updating often points to WordPress .htaccess rewrite rule problems or mismatches between site address protocols (HTTP versus HTTPS). Refreshing permalinks or deactivating conflicting plugins resolves these rewrite discrepancies.

Open the JSON Formatter

Frequently asked questions

Why does my JSON fail validation even though the characters look right?
JSON string literals forbid raw, unescaped literal newlines; line breaks must be written as \n. In addition, special formatting like bullet characters or lack of percent-encoding in HTTP parameters can cause validation to fail.
What causes an invalid JSON response error when submitting forms?
This usually happens when the endpoint outputs an HTML error page instead of JSON, often caused by plugin conflicts, incorrect HTTP/HTTPS site URL settings, or corrupted rewrite rules.
How can bullet points in an email body cause an invalid JSON error?
Certain form-signing applications automatically serialize your message body into JSON. If the serializer cannot handle bullet characters or special symbols, it produces malformed JSON and rejects the submission.
How do form parameters affect JSON validity in custom HTTP calls?
If you craft an HTTP request yourself and submit JSON inside form parameters, the data must be percent-encoded so the receiving server can parse the parameter value as valid JSON.