Please explain the logic of the HTTP request node in test mode

Hey!
I ask for clarification on the principle of operation of the HTTP request node.

  1. Before the HTTP request node, I have a set node, which gives 125 data lines.
  2. The HTTP request node sends data to the webhook to another wolflow inside the h8n.

In test mode, I cannot send all 125 lines inside the HTTP request, the node sends only one line to the webhook. Is this the correct operation of the node?
To set up the logic of the next workflow, I need the entire data array of 125 lines. How can i do this?

Do you want to make 1 request or 125?

I need to send one request with 125 lines.

Ok, then I guess you mean you want to send an array that contains 125 objects?

Yes exactly.

Then you need a Function-Node with this code to combine it:

return [
  {
    json: {
      data: items.map(item => item.json)
    }
  }
];

Here the example in the docs:

And here an example workflow:

{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/c9c4416b-204b-42ca-95b6-175bc19ae236",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={{$json[\"data\"]}}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      character: 'a'\n    }\n  },\n  {\n    json: {\n      character: 'b'\n    }\n  },\n  {\n    json: {\n      character: 'c'\n    }\n  }\n];"
      },
      "name": "Mock Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      data: items.map(item => item.json)\n    }\n  }\n];\n"
      },
      "name": "Combine Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        700,
        300
      ]
    }
  ],
  "connections": {
    "Mock Data": {
      "main": [
        [
          {
            "node": "Combine Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Data": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

OK, thanks Jan!
I know this method, sorry that you had to give me such a simple (for you) recommendation again).
But, I would like to once again clarify the very principle of operation.
That is, we combine into one object before sending, and if we had not done this, then by default the HTTP request node will make 125 requests with each object in the activated workflow mode?
Am I understanding the principle correctly?

Sure, that is what I am here for.

Exactly. n8n nodes do normally do their operation once per incoming item (with a few exceptions which we want to fix soon).
It operates always like that no matter if when executing manually or in production-mode.

1 Like

Jan, again the same situation.
I can not understand(.
Now with the Google Sheets node.
Why update only one row?
n8n - ▶️ - Google Chrome 2021-03-25 16.59.52

Hard to say without knowing what data the node receives and what parameters you have set. The node is for sure one of the exceptions I mentioned above as it reads the key name only for the first item, but that is normally not a problem as they key name does not change in 99% of the cases.
So I guess you have either one of that 1% use-cases or the node is not configured correctly.

It was some kind of bug).
I deleted the current Google Sheets node and created a new one with the same settings and everything works.
Updated:
It was in the settings of the copied Google Tables node, the “Execute Once” setting was installed there.

Glad to hear that you found the problem!

1 Like