The problem
Note: I usually use the community node Browserless, but for this specific case I have to call the API directly via an HTTP Request node.
I want to execute a Playwright script on browserless from n8n by sending:
- My JavaScript (Playwright) code
- A context containing dynamic variables (postUrl, userAgent, extraHeaders, seedCookieList, timeoutMs, etc.)
Working Case (Hardcoded)
When I use hardcoded variable, everything works fine
{
"code": "export default async function (...) { /* … */ }",
"context": {
"postUrl": "https://example.com/",
"userAgent": "Mozilla/...",
"extraHeaders": { "accept-language": "fr-FR,..." },
"seedCookieList": [ /* static array */ ],
"timeoutMs": 45000
}
}
Problem with Dynamic Variables
As soon as I use the {{ ... }} syntax in the jsonBody to inject data from a Set node or other nodes, I always get:
{
"errorMessage": "JSON parameter needs to be valid JSON",
"errorDetails": {},
"n8nDetails": { /* … */ }
}
The generated JSON is either truncated or invalid (the seedCookieList array disappears or becomes corrupted, like “Object Object” ), even though the Set node’s output contains a valid array.
Exact Error Message
NodeOperationError: JSON parameter needs to be valid JSON
Minimal Workflow to Reproduce
I’ve simplified my node as much as possible. The original contained a very complex script plus private data (personal cookies). This minimal example should give a clear idea of what I’m trying to do.
Feel free to replace the URL with your own browserless endpoint and insert your token. The “Simple Code with Dynamic Variables” node works correctly.
Output of the HTTP Request Node
{
"errorMessage": "JSON parameter needs to be valid JSON",
"errorDetails": {},
"n8nDetails": {
"nodeName": "FINAL5",
"nodeType": "n8n-nodes-base.httpRequest",
"nodeVersion": 4.2,
"itemIndex": 0,
"time": "05/08/2025 19:21:07",
"n8nVersion": "1.101.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"NodeOperationError: JSON parameter needs to be valid JSON",
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts:366:15)",
" at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1194:32)",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1564:38",
" at processTicksAndRejections (node:internal/process/task_queues:105:5)",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2135:11"
]
}
}
n8n Environment
- Version: 1.101.2 (Self Hosted)
- Database: Postgres
- EXECUTIONS_PROCESS: own
- Running via: npm (self‑hosted)
- OS: Ubuntu 22.04 LTS
Context: I must use an HTTP Request because the Browserless node doesn’t fit this use case. My goal is to pass a moderately complex script and dynamic variables (including a cookie array). The JSON body breaks as soon as I add those dynamic variables via {{ … }}, invalidating the JSON and preventing execution.
Objective: Understand why the dynamic variable (array) isn’t inserted correctly and how to build the jsonBody so it remains valid JSON. Any help is appreciated! Cheers ![]()
