Http node body array help

Hey,

My problem is happening in the http node

I’m trying to send a POST request so I’m using body params option in the node
but the issue is that I can send an array in one of the attributes being used
it’s either a string OR empty array when I put the my array in {{}}
Screenshot_19

any thoughts ?
Thanks

Hi @Mohamed_Reda, so you’re trying to POST an array using the HTTP Request node? I think this workflow would do the job:

I am specifying my array as an expression here which does the job. It arrives on the server as an actual array (not a stringified or empty array):

image

Hope this helps!

consider this is the array I want to use in a contacts field in the body request

[ {
            "name": "M El-Haball",
            "title": "Booking",
            "emails": [
                {
                    "type": "office",
                    "email": "[email protected]"
                }
            ],
            "phones": []
        }]

considering it will have values being inserted from the previous node

can you make the example based of that ?

That should be possible, can you confirm the JSON output from your previous node? This will help with getting the expressions right.

Screenshot_21

it’s not giving the array that’s what I used in my http node


= {{
[
        {
            "name": "{{$json["name"]}}",
            "title": "Booking from Calendly",
            "emails": [
                {
                    "type": "office",
                    "email": "{{$json["email"]}}"
                }
            ],
            "phones": []
        }
    ]
}}

Okay, so the JSON data you have shared is the data you already have in n8n?

If so, you could POST the existing data structure for a single item like so:

It arrives on the receiving end like this:

image

it must arrive in the format of array shape

[
        {
            "name": "{{$json["name"]}}",
            "title": "Booking from Calendly",
            "emails": [
                {
                    "type": "office",
                    "email": "{{$json["email"]}}"
                }
            ],
            "phones": []
        }
    ]

Try this:

Result:

Or does your incoming data look different from what the Mock Data node is sending? If so, can you confirm the exact JSON data you are sending to the HTTP Request node in your workflow?

got it working, thanks alot for your help

1 Like

Sweet, thx for confirming!