HTTP node works with content in fixed body but not as expression

Hey, I’m trying to send

a POST request via the HTTP node. I got some mock data in a webhook as a starting point. If I manually copy and paste the output from the webhook into the HTTP nodes body it works fine. If I try to map the data via the expression funtion I get an 422 error from the endpoint. I don’t see any different in my data.

I tried the expressions

{{ $node["Webhook"].json["body"] }}
{{ $json["body"] }}
{{ $json }}

and different options with stringify an parse

Describe the issue/error/question

HTTP node works if I manually copy the body from previous node into fixed body of HTTP node but not If I use the expression to do the same

What is the error message (if any)?

ERROR: Your request is invalid or could not be processed by the service

Please share the workflow

(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

Share the output returned by the last node

{"status":"rejected","reason":{"message":"422 - \"{\\\"message\\\":\\\"The type field is required.\\\",\\\"errors\\\":{\\\"type\\\":[\\\"The type field is required.\\\"]}}\"","name":"Error","stack":"Error: Request failed with status code 422\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (node:events:525:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"}}

Information on your n8n setup

  • n8n version: 0.206.1
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own, main
  • Running n8n via [Docker, npm,, desktop app]: Docker

Hey @nxtgen,

Welcome to the community :tada:

The web service you are calling is saying you are missing a field, Without seeing your workflow it is hard to say what is going on but most of the time when something like this happens it tends to be that the data is missing in an input.

If the node you are getting the data is from is before the HTTP Request node you would want to use {{$json["body"]}} assuming that has all the data you are after but if you have multiple items coming in you would need to make sure everything is there. One thing I would try is sending the data off to something like to see what is being sent that will allow you to debug it a bit more.

Hey Jon,

thanks for the reply. Attached you will find my workflow as it looks right now. I tried to send over the data to and the data looks fine. And since the data works fine If I copy it manually from the webhook to the HTTP node I also know that nothing is missing. I get a positive reponse from the ednpoint with the manual copied data.

Hey @nxtgen,

Are you able to share the data that you have coming out from the webhook node? I suspect that $json isn’t gong to be the correct option. Are you also able to share what the service is expecting to receive? The error from the service mentions a “type” field so I suspect that is what is missing.

Hi @Jon ,

I also tried {{$json[“body”]}} but I always get the same result. The code from the webhook is the following. The output also works in Postman. So data wise everything is correct.

I made some changes to the fields to anonymize the data. That means it woudn’t go through the http node but the structure is still the same.

"{"type":"INVOICE","content":{"items":[{"tax":{"amount":4.935,"percentage":7},"quantity":3,"unitPrice":25,"lineNumber":1,"description":"Test","identifiers":[{"domain":"GS1","identifier":"111"}],"isDepositItem":false,"unitOfMeasure":"EA","modificationGroups":[{"basis":75,"level":1,"modifications":[{"type":"ALLOWANCE","percentage":6,"reasonCode":"DISCOUNT"}]}]}, {"tax":{"amount":0.56,"percentage":7},"quantity":2,"unitPrice":4,"lineNumber":2,"description":"Test","identifiers":[{"domain":"GS1","identifier":"111"}],"isDepositItem":false,"unitOfMeasure":"EA","modificationGroups":[{"basis":8,"level":1,"modifications":[{"type":"ALLOWANCE","percentage":0,"reasonCode":"DISCOUNT"}]}]}],"header":{"buyer":{"identifiers":[{"domain":"GS1","identifier":"111"}]},"billTo":{"identifiers":[{"domain":"GS1","identifier":"111"}]},"shipTo":{"identifiers":[{"domain":"GS1","identifier":"111"}]},"currency":"EUR","supplier":{"identifiers":[{"domain":"GS1","identifier":"111"}]},"orderDate":"2022-12-07","invoiceDate":"2022-12-07","paymentTerms":[{"percentage":10,"payInNumberOfDays":40}],"orderIdentifier":"2210200015","invoiceIdentifier":"2210400012-16","shippingNoticeDate":"2022-12-07","shippingNoticeIdentifier":"EL00000011"},"summary":{"tax":{"items":[{"category":"sales","taxAmount":4.94,"percentage":7,"taxableAmount":70.5}],"total":4.94},"dueAmount":75.44,"netAmount":70.5,"grossAmount":75.44,"totalCharges":0,"subtotalAmount":78.5,"totalAllowances":8,"modificationGroups":[{"basis":78.5,"level":1,"modifications":[{"type":"ALLOWANCE","percentage":10.191083,"reasonCode":"DISCOUNT"}]}]}}}"

Hey @nxtgen,

Have you tried {{ JSON.parse($json["body"]) }} it looks like the body is a string so would probably be sent as one which is why the service can’t find the value.

Hi @Jon,

I thought about that as well but I get an undefinied for the body when I try to implement the parse. If I look at the result in webhook tester the body is also empty.

That is odd when I try it I see the below, Do you have some input data in the workflow?

Hey @Jon,

Yes, I have. Attached my sample screenshot.

Hey @nxtgen,

That is a bit odd, Maybe the data you have is already treated as JSON then… Do you have access to the service you are sending the data to? It would be handy to know what it is actually getting, I am fairly sure n8n is sending what it is being told to so we will need to know what the other service is getting for it to think the field isn’t there.

Hey @Jon,

I figured that they are expecting a 100% valid JSON structure and I had only a space between my items instead a tab. After I replaced the seperator it worked fine.
But thanks for the help. It helped me to figure out that the problem is not setup related.

1 Like

Hi guys,

If it can help, I have the same problem.

I try to send a request to Microsoft Teams webhook.

If i send with this options it’s ok :

If I send with this options, i have an error :

The error :
ERROR: Bad request - please check your parameters

HTTP Code : 400

Cause :

{"status":"rejected","reason":{"message":"400 - {\"type\":\"Buffer\",\"data\":[83,117,109,109,97,114,121,32,111,114,32,84,101,120,116,32,105,115,32,114,101,113,117,105,114,101,100,46]}","name":"Error","stack":"Error: Request failed with status code 400\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (node:events:525:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1359:12)\n    at processTicksAndRejections (node:internal/process/task_queues:82:21)"}}

Stack :

NodeApiError: Bad request - please check your parameters
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts:1305:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1270:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:939:29

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.