-
Support
- 400 Bad Request - Invalid/malformed JSON in request
Business
-
Account & Licensing
-
Installing & Updating
-
Power Pick Connections
-
Data Push & Data Pull
-
API
-
Reports
-
Snapshots & Dashboard
-
Workflows
400 Bad Request - Invalid/malformed JSON in request
Issue:
The API receives malformed JSON or invalid data (such as missing required fields) that the server cannot process, resulting in a 400 Bad Request error.
Resolution:
Check your JSON for typos (like missing commas), make sure all required fields are included, and double-check that your data matches the formats in our ItemPath API guides.
Think of a 400 Bad Request error as the system saying, "I can hear you, but I don't quite understand what you’re asking for." The good news is that your connection and authentication are working!
A 400 error can occur for various reasons. Luckily, ItemPath typically returns a specific error message alongside the 400 status code. If the error message indicates "Invalid/malformed JSON in request", this means there is something a little "off" with the JSON package you’re sending. Usually, it’s just a tiny typo or a missing detail that’s preventing ItemPath from processing your request.
Common Causes of Bad JSON
When sending Orders or Materials, the most common culprits for a 400 error include:
- Syntax Errors:
- Missing or extra commas: Forgetting a comma between key-value pairs or leaving a "trailing comma" at the end of a list.
- Unmatched brackets: Every opening brace
{or bracket[needs its partner to close it. - “Smart” Quotes: If you copy-pasted from a document, you might have “curly” quotes instead of the standard "straight" quotes (") the API requires.
- Missing Required Fields:
- Orders: Every order requires a
name(the unique order number) and anorder_linesarray. - Materials: Creating a material requires a
name.
- Orders: Every order requires a
- Data Type Mismatches: Sending a string where an integer is expected (e.g., sending
"priority": "high"instead of the required integer value like"priority": 3).
Troubleshooting Tips
- Review the Error Message: ItemPath typically returns a specific error message alongside the 400 status code. Check the Logs in ItemPath or create a report of recent API errors.
- Tip: If you are using an automated script and can't see the response, check the API Calls endpoint in ItemPath (
/api/api_calls) to view a log of recent requests and their specific error details.
- Tip: If you are using an automated script and can't see the response, check the API Calls endpoint in ItemPath (
- Validate Your Syntax: Copy your JSON body and paste it into a free online JSON Validator or JSON Lint tool. These tools will highlight exactly where a missing comma or bracket is located.
- Cross-Reference the Documentation Ensure your JSON matches the requirements for the specific resource you are hitting:
- Check for Hidden Characters If you are copying data from an Excel sheet or a PDF, hidden formatting characters can sometimes sneak into your JSON strings. Try re-typing the values manually or using a "Paste as Plain Text" option.