Passing output from Set Node into Http Request body

Is there a easy way to pass the full set ouput into the http request body field? I can add each name / value but have to also format it all which is kind of a pain. I have verified if I copy this full output into the body field it works perfectly.

Hi @Ben_Hui, first of all, welcome to the community! I love the customized colour scheme from your screenshot!

So you’d essentially want to use key value pairs in the Set node which will then be used as the JSON body in an HTTP request, right? This should do the trick:

Example Workflow
{
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "foo",
              "value": "Hello World"
            }
          ],
          "number": [
            {
              "name": "bar",
              "value": 12345
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://hookb.in/oXroqB91YasBnPZZnwML",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={{$json}}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

This example uses the JSON/RAW Parameters option offered by the HTTP Request node (to accept the body parameters as a JSON blob) and then just sets the body parameters to an expression consisting of the $json variable (which contains the incoming JSON data of a node).

In this example workflow, this would be the body sent to Hookbin:
image

1 Like

Thank you so much… no need to json.stringify or any other work arounds. {{$json}} was all that was needed in the http body field. Awesome

2 Likes