Post request lists of in a desired ordering

Hi
I’m creating records using Http Request node through a list of items.
I am arranging the lists in the desired order following which is important.
But the requests do not follow the order of the list.
See example my workflow…

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const newItems = [];\n\nfor (let i=0;i<200;i++) {\n  newItems.push({\n    json: {\n      \"ID\": i+1,\n      \"Date\": \"2021-09-01T22:00:00.000Z\",\n      \"OrderID\": \"666000000483\",\n      \"Description\": \"ManMar Esch\",\n      \"Currency\": \"EUA\",\n      \"Amount\": \"3.96\",\n    }\n  });\n}\n\nreturn newItems;\n\n"
      },
      "name": "DATA",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        490,
        240
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/bff8a016-ec7d-4354-8c46-998df31afda8",
        "responseFormat": "string",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "raw"
        },
        "bodyParametersJson": "={\n\"ID\": \"{{$node[\"DATA\"].json[\"ID\"]}}\",\n\"Currency\":\"{{$node[\"DATA\"].json[\"Currency\"]}}\",\n\"Date\": \"{{$node[\"DATA\"].json[\"Date\"]}}\",\n\"OrderID\": \"{{$node[\"DATA\"].json[\"OrderID\"]}}\",\n\"Description\": \"{{$node[\"DATA\"].json[\"Description\"]}}\",\n\"Amount\": \"{{$node[\"DATA\"].json[\"Amount\"]}}\",\n}"
      },
      "name": "POST-REQUEST",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        750,
        180
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "DATA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DATA": {
      "main": [
        [
          {
            "node": "POST-REQUEST",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

See sequence request…


Hi @Edson_Rodrigues, n8n would process the requests sequentially, but will send them out individually in very fast succession, so the destination might not process them in the same order (especially likely for distributed systems).

You could add options for Batch Interval and Size like so to prevent this:
image

Now when checking the incoming requests on webhook.site you should see these requests in the correct order (ID 1 first, ID 200 last).

Awesome @MutedJam
Thank you so much
This is what I was after.
My problem is solved.

1 Like