The problem/error/question
I am trying to pass a content from Google Docs to a HTTP request. After viewing the content is ready in the previous node, I pass this content to OpenAI’s responses API as user input_text.
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "{{ $json.content }}"
}
]
}
“text”: “{{ $json.content }}” this causes the error. Having a constant string, I can send the request. But cant use the input from previous code node.
The error message
JSON parameter needs to be valid JSON
My workflow
{
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “https://api.openai.com/v1/responses”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Content-Type”,
“value”: “application/json”
},
{
“name”: “Authorization”,
“value”: “Bearer Token”
}
]
},
“sendBody”: true,
“specifyBody”: “json”,
//here is the json input. When I write a constant string as text it workds
“jsonBody”: " {\n "role": "user",\n "content": [\n {\n "type": "input_text",\n "text": "{{ $json.content }}"\n\n }\n ]\n }\n ],\n "text": {\n "format": {\n "type": "text"\n }\n },\n "reasoning": {},\n "tools": ,\n "temperature": 1,\n "max_output_tokens": 2048,\n "top_p": 1,\n "store": true\n}",
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
2960,
20
],
“id”: “myid”,
“name”: “HTTP Request4”
},
{
“parameters”: {
“jsCode”: “const items = $input.all();\n\nconst updatedItems = items.map((item) => {\n const cleanedContent = item.json.content.replace(/\n/g, " ");\n item.json.content = Source: blog-url Target: (some text)[some-text] ${cleanedContent}
;\n return item;\n});\n\nreturn updatedItems;”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
2760,
80
],
“id”: “a739d218-4bf6-498b-899a-8fb5464d8052”,
“name”: “Code1”
}
],
“connections”: {
“HTTP Request4”: {
“main”: [
]
},
“Code1”: {
“main”: [
[
{
“node”: “HTTP Request4”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “instanceID”
}
}
Output returned by the last node
{
“documentId”: “my_document_id”,
“content”: “Source: blog-url Target: (some word)[some-word] Content”
}
JSON parameter needs to be valid JSON
Information on your n8n setup
- **n8n version: 1.79.3
- **Database (default: SQLite): default
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: