Webhook to HTTP request

I’m trying to get the most simple workflow to work but I am unable to.

I setup a webhook to HTTP request and I want to relay the data received by the webhook into the HTTP request. But the target body is always empty.

How do I send the data?

In requestbin:

image

What am I missing here?

Apparently I can only post one image per post…

image

Welcome to the community @Zyles!

You can send multiple files with multipart-form-data. Here an example:

{
  "nodes": [
    {
      "parameters": {
        "url": "https://imgs.chip.de/2eqbJ_mnNYnL6N32N25VpDV0TvE=/220x220/filters:format(jpeg):fill(fff,true)/www.chip.de%2Fii%2F2496016366_bb52b941cf.jpg",
        "responseFormat": "file",
        "dataPropertyName": "data1",
        "options": {}
      },
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://imgs.chip.de/2eqbJ_mnNYnL6N32N25VpDV0TvE=/220x220/filters:format(jpeg):fill(fff,true)/www.chip.de%2Fii%2F2496016366_bb52b941cf.jpg",
        "responseFormat": "file",
        "dataPropertyName": "data2",
        "options": {}
      },
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://localhost:5678/webhook-test/307/webhook/webhook",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "multipart-form-data"
        },
        "sendBinaryData": true,
        "binaryPropertyName": "k1:data1,l2:data2"
      },
      "name": "HTTP Request3",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "HTTP Request3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

The webhook node will then receive these multiple files just fine.

I am sending a body of:

{ sku: 123 }

To the webhook. And I want to pass this on to the HTTP request.

Not multipart files.

The webhook is receiving the request but the data is not passed on.

1 Like

Here an example workflow which mocks the data you have and then sends it to https://webhook.site/:

{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/214ecffc-3a03-47a0-94ca-877641df82c1",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={{$json[\"body\"]}}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "items[0].json.body = { sku: 123 };\nreturn items;"
      },
      "name": "Mock Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    }
  ],
  "connections": {
    "Mock Data": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

So it is not possible to pass data from a webhook to a HTTP request directly without an intermediary function?

Yes, it is. I posted an example you can execute. You simply remove the Function-Node and plug in the Webhook-Node instead.

1 Like