Data Structure not working in HTTP Post Request

Describe the problem/error/question

My workflow needs to pull contact list using HTTP Get request and then extract the phone no.s into an array of key value pairs to be fed into another HTTP Post request to send them a message.
Superficially I am able to do this using Item List node and feed it into the HTTP Post node. But when the actual work flow is executed the receiving application is returning error saying “Request is null” in the Post Request.
Interestingly, if I type in the data being feed into the Post Request as a fixed type the Post request is successful but same is not working if the data is being fed as an expression from previous input.

What is the error message (if any)?

There is no error in n8n but the application to which the Post request is being sent is returning error message that the Request is Null

Please share your workflow

{
  "meta": {
    "instanceId": "4c31310b58ef91b7a2d91da674664f6eab9ef928599acca38707adcca0b10233"
  },
  "nodes": [
    {
      "parameters": {
        "fieldToSplitOut": "contact_list",
        "options": {
          "destinationFieldName": "contact_list"
        }
      },
      "id": "9e8cf9b1-6a67-47e4-8444-bcc37e3290ce",
      "name": "Receivers 1",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3,
      "position": [
        1020,
        260
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8-22 * * *"
            }
          ]
        }
      },
      "id": "d1a80074-04d4-45ac-8160-2b28beec4136",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        300,
        260
      ]
    },
    {
      "parameters": {
        "operation": "subtractFromDate",
        "magnitude": "={{ $now }}"
      },
      "id": "7ea24211-f8b7-412f-b0c0-b5eea123ccfc",
      "name": "Date & Time1",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        480,
        260
      ]
    },
    {
      "parameters": {
        "operation": "formatDate",
        "date": "={{ $json.newDate }}",
        "format": "yyyy-MM-dd",
        "options": {}
      },
      "id": "624e250c-db5c-4a67-9fda-f6e126706109",
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        640,
        260
      ]
    },
    {
      "parameters": {
        "url": "=https://____________________________________
pageSize=1000&attribute=%5B%7Bname%3A%20%22phone%22%2C%20operator%3A%20%22contain%22%2C%20value%3A%20%229170329%22%7D%5D",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "_________________"
            }
          ]
        },
        "options": {}
      },
      "id": "3bb28835-14d4-4d9d-866c-09c63355cb9f",
      "name": "Get Receivers",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        800,
        260
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "contact_list.phone",
        "options": {
          "destinationFieldName": "whatsappNumber"
        }
      },
      "id": "5b5e76e6-4619-4b87-b825-63d3c000b15d",
      "name": "Receivers 2",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3,
      "position": [
        1260,
        260
      ]
    },
    {
      "parameters": {
        "operation": "concatenateItems",
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "Receivers",
        "options": {}
      },
      "id": "ffc28418-0501-4744-8f38-cc6ebdd72d9f",
      "name": "Receivers 3",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3,
      "position": [
        1480,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://______________________/sendTemplateMessages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "_____________________"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "text/json",
        "body": " { \"template_name\": \"users_pic_30mfu\", \"broadcast_name\": \"2023-11-06_21_1_2\", \"receivers\": [{{ $json[\"Receivers\"] }}] }",
        "options": {}
      },
      "id": "a44ab394-faa0-491d-9ff7-3d34c31c26e2",
      "name": "Send 1_2 Msg",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1680,
        260
      ]
    }
  ],
  "connections": {
    "Receivers 1": {
      "main": [
        [
          {
            "node": "Receivers 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Date & Time1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time1": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Get Receivers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Receivers": {
      "main": [
        [
          {
            "node": "Receivers 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receivers 2": {
      "main": [
        [
          {
            "node": "Receivers 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receivers 3": {
      "main": [
        [
          {
            "node": "Send 1_2 Msg",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Share the output returned by the last node

[
{
“result”: false,
“errors”: {
“error”: “Request is null”,
“invalidWhatsappNumbers”: ,
“invalidCustomParameters”:
}
}
]

Share the expected output returned by the last node

[
{
“result”: true,
“errors”: {
“error”: “”,
“invalidWhatsappNumbers”: ,
“invalidCustomParameters”:
}
}
]

Information on your n8n setup

  • n8n version: [email protected]
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: Windows 10





Hi @Sepal_Labs, welcome to the community!

I am sorry you are having trouble.

This would be an error coming from your API, so I am not quite sure what might be wrong here. But we can certainly look at your expression.

Can you share an example of the JSON data you’re sending to the HTTP Request node when running into this problem and also an example of the hard-coded data working for you here (so I can compare the two and hopefully spot the problem)?

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