Hello n8n Community,
I am reporting a critical and reproducible bug where the HTTP Request node consistently fails with a JSON parameter needs to be valid JSON error, whenever I try to use an expression to set the body.
This issue occurs on multiple, independent n8n instances, including a brand new, clean n8n cloud account, and a self-hosted instance on Hostinger.
My Environment:
- n8n Version: Latest on n8n Cloud (and also tested on self-hosted 1.113.3)
- Database: SQLite (Default)
- Running n8n via: Docker (self-hosted) and n8n Cloud.
Minimal Reproducible Example:
Here is the simplest possible workflow that demonstrates the bug. It uses only two core nodes.
Node 1:CodeNode
This node creates a simple, valid JavaScript object.
Code:
return [{ json: { my_data: { user: "test", id: 123 } } }];
Node 2:HTTP RequestNode
This node attempts to send the object from the first node as its body to a public test endpoint. - Method:
POST - URL: (I used a webhook.site URL to test)
- Send Body: ON
- Body Content Type:
JSON - Specify Body:
Using JSON - JSON field (The Failing Expression):
={{ $json.my_data }}
Expected vs. Actual Behavior: - Expected Behavior: The
HTTP Requestnode should successfully send the JSON body{"user":"test","id":123}. - Actual Behavior: The node fails immediately with the error
JSON parameter needs to be valid JSON.
Crucial Troubleshooting Information: - Static JSON works perfectly: If I replace the expression
={{ $json.my_data }}with a hardcoded static JSON string{"user":"test","id":123}, the request is sent successfully. This proves that the destination URL and network are all fine. - Workarounds also fail: I have also tried creating a JSON string in the
Codenode usingJSON.stringify()and passing it to theHTTP Requestnode’sExpressionfield. This also results in the same error.
Conclusion:
This seems to be a fundamental bug in how the n8n expression engine passes evaluated data to theHTTP Requestnode’s body parameter. This is a critical issue as it prevents the creation of any dynamic POST requests.
Could the team please look into this?
Thank you for your help.
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: