I am trying to enter an array of domains in the body parameter of a HTTP Request and unfortunately it seems to only accept strings as entry. I know I can tick the box for JSON/RAW Parameters however I do not currently have the coding knowledge to be able to write the body parameters in JSON.
Is there anyway for me to use the UI provided but input the data as an array rather than a string?
Any help would be much aprreciated!
Welcome to the community @aziadlourad
You can define the array with a expression: {{["1","2",'3"]}}
Example Workflow
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"requestMethod": "POST",
"jsonParameters": true,
"options": {},
"bodyParametersJson": "={{[1,2,3]}}"
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
590,
300
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}
Thanks for the quick reply Ricardo! Unfortunately when I enter the data in the format provided it still says “Domains must be an array”
Can you share an example of the body you want to send?
In the picture, the domain value it’s no an expression nor an array.
Try it like this:
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"requestMethod": "POST",
"options": {},
"bodyParametersUi": {
"parameter": [
{
"name": "domains",
"value": "={{['https://google.com', \"https://n8n.io\"]}}"
}
]
}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
590,
300
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}
Great thank you! That worked
Glad that it worked. Have fun.
Now i seem to have another error. I am trying to use the website domain outputted from a node earlier on in the workflow, however it gives me this error.
You have one extra set of curly brackets. Check the example below:
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "domain",
"value": "https://n8n.io"
}
]
},
"options": {}
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
470,
300
]
},
{
"parameters": {
"url": "={{$node[\"Set\"].json[\"domain\"]}}",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "domains",
"value": "={{[$node[\"Set\"].json[\"domain\"]]}}"
}
]
}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
670,
300
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
},
"Set": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}
Sorry i don’t understand which bit you mean has too many curly brackets?
Did you check the last workflow? If you compare that to yours, you are going to notice the difference.
Ah when i remove those brackets it says the entry is no longer an array.
Hey @aziadlourad, do you want to pass on all the values from the Google Sheets node to the HTTP Request node as an array?
Can you share the output from the Google Sheets node? Make sure to hide any private information.
Hi Harshil,
Yep so I have a domain output in my google sheet, and I need to pass on the value into the HTTP node. The HTTP Request requires the input to be an array, so i need to pass the value from the google sheet as an array.
Do you want the output as JSON or in table form?
Thanks
Hey,
Thanks for clearing that for me. Another question, do you want to send all of these together, or do you want to send them individually?
Right now, you’re receiving records from the Google Sheet node. The next node, the HTTP Request node will process all the records individually. You will have to convert the data structure (I will share an example for it ) and then pass it on to the HTTP Request node if you want to send these values in a single request.
If you can share the JSON it would be perfect
I want to send one domain individually from my Google Sheet node to the HTTP request node.
The JSON actually contains all sensitive information unfortunately. The format is just
[
{
“Testing 123?”: “Testing 456”,
Alright! This expression should do the trick then {{[$node["Set"].json["domain"]]}}
You will have to replace Set
with the name of your Google Sheets node and domain
with the column name that contains the domains.
Ah fantastic, it worked! Thank you so much
1 Like