HTTPRequest sending single variable as JSON

Describe the problem/error/question

What is the error message (if any)? Bad request - please check your parameters

Please share your workflow

{
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “http://host.docker.internal:8082/api/assistant/intent”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Content-Type”,
“value”: “application/json”
},
{
“name”: “Accept”,
“value”: “application/json”
}
]
},
“sendBody”: true,
“contentType”: “raw”,
“body”: “={{ $json.cleanOutput }}”,
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.4,
“position”: [
240,
-112
],
“id”: “bc555ae5-8565-4c9b-b871-4d3f4a20899b”,
“name”: “HTTP Request”
}
],
“connections”: {},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “02f1001f8f2d972f69be23b2f2dcfdcc65885dd6f6ff6d04c911329ee6f7f3dd”
}
}

Information on your n8n setup

  • n8n version: latest / local
  • Database (default: SQLite): N/A
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows 10

Hi @GeoForeman

Change your Body field to this:

{
  "intent": "{{ $json.cleanOutput }}"
}

(Replace "intent" with the actual key name required by your API).

Hi @GeoForeman Welcome!
Content type raw sends the literal value of the expression as the body. If cleanOutput isn’t already valid JSON, host.docker.internal:8082 receives plain text under a Content-Type: application/json header, and its parser rejects it before your endpoint logic runs.
Wrap the value with JSON.stringify instead of typing quotes around the expression, manual quoting breaks the moment cleanOutput contains a quote or newline:

{{ JSON.stringify({ yourKey: $json.cleanOutput }) }}

Since this is your own local service, its actual response body or server log will show the real validation reason instead of n8n’s generic message.

Thanks it worked