Handling Json array data from spreadsheet and send through HTTP

Please check the screen shot.

I am getting the following output from the spreadsheet node.

I need to upload the data to rest API in following format

[
{
“key1”: “value1”,
“body”: “This is our first article”
},
{
“title”: “Hello again, world!”,
“body”: “This is our second article”
}
]

I tried using expression in HTTP node but I don’t know which will be the right expression to view the complete json from the spreadsheet node so I can use it properly to add it to HTTP body parameters

Hey @Priya_Kumar,

If you’ll wait until all data will be downloaded on the left side you will see available options.
I don’t understand which data you want to use but for example if you would like to use Client_name you would write sth like that {{$node["Spreadsheet File"].json.Client_name}}

You said that you want to send it to rest API so try to use request node

{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "someurl",
        "options": {},
        "queryParametersUi": {
          "parameter": [
            {
              "name": "clientOrSthElse",
              "value": "={{$node[\"Spreadsheet File\"].json.Client_name}}"
            }
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        40,
        0
      ]
    }
  ],
  "connections": {}
}
1 Like

Thanks for your response.

I tried the expression shared but I am getting below response. don’t know the right expression for the attached json file

spreadsheet output json is like this

[

{

“Client_Name”: “Client 4”,

“Client_Id”: 45325,

“Client_Type”: “DIRECT”,

“Point”: 22.91

},

{

“Client_Name”: “Client 4”,

“Client_Id”: 45325,

“Client_Type”: “DIRECT”,

“Point”: 22.91

}
]

My found should be {{$node["Spreadsheet File"].json.Client_Name}} if not try also {{$node["Spreadsheet File"].Client_Name}}

BTW. please share your code inside ``` code ```

Please check the workflow attached. I don’t have a clue how to send spreadsheet data to HTTP and Airtable.?

{
“nodes”: [
{
“parameters”: {
“triggerTimes”: {
“item”: [
{
“mode”: “everyMinute”
}
]
}
},
“name”: “Cron”,
“type”: “n8n-nodes-base.cron”,
“position”: [
860,
1100
],
“typeVersion”: 1
},
{
“parameters”: {
“functionCode”: “\nconst date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split(“T”)[0].split(”-");\nitem.date = ${date[1]}-${date[2]}-${date[0]};\nreturn item;"
},
“name”: “Get Date”,
“type”: “n8n-nodes-base.functionItem”,
“position”: [
1200,
1100
],
“typeVersion”: 1
},
{
“parameters”: {
“url”: “=https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{{$json[“date”]}}.csv”,
“responseFormat”: “file”,
“options”: {},
“headerParametersUi”: {
“parameter”: []
},
“queryParametersUi”: {
“parameter”: []
}
},
“name”: “Fetch Script”,
“type”: “n8n-nodes-base.httpRequest”,
“position”: [
1440,
1100
],
“typeVersion”: 1
},
{
“parameters”: {
“options”: {}
},
“name”: “Spreadsheet File2”,
“type”: “n8n-nodes-base.spreadsheetFile”,
“typeVersion”: 1,
“position”: [
1740,
1100
],
“executeOnce”: false
},
{
“parameters”: {
“requestMethod”: “POST”,
“url”: “http://localhost:8080”,
“options”: {},
“bodyParametersUi”: {
“parameter”: [
{
“name”: “={{$node[“Spreadsheet File”].json}}”
}
]
},
“headerParametersUi”: {
“parameter”: [
{
“name”: “Content-Type”,
“value”: “application/json”
}
]
}
},
“name”: “HTTP Request5”,
“type”: “n8n-nodes-base.httpRequest”,
“position”: [
2140,
1100
],
“typeVersion”: 1,
“alwaysOutputData”: false,
“retryOnFail”: true
},
{
“parameters”: {},
“name”: “Airtable”,
“type”: “n8n-nodes-base.airtable”,
“typeVersion”: 1,
“position”: [
2140,
1320
],
“credentials”: {
“airtableApi”: {
“id”: “1”,
“name”: “Airtable account”
}
}
}
],
“connections”: {
“Cron”: {
“main”: [
[
{
“node”: “Get Date”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get Date”: {
“main”: [
[
{
“node”: “Fetch Script”,
“type”: “main”,
“index”: 0
}
]
]
},
“Fetch Script”: {
“main”: [
[
{
“node”: “Spreadsheet File2”,
“type”: “main”,
“index”: 0
}
]
]
},
“Spreadsheet File2”: {
“main”: [
[
{
“node”: “HTTP Request5”,
“type”: “main”,
“index”: 0
},
{
“node”: “Airtable”,
“type”: “main”,
“index”: 0
}
]
]
}
}
}

I am able to send the sing json object of the array through HTTP but don’t know how to send a complete JSON array to through HTTP Node

{
  "nodes": [
    {
      "parameters": {
        "url": "=https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{{$json[\"date\"]}}.csv",
        "responseFormat": "file",
        "options": {},
        "headerParametersUi": {
          "parameter": []
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "Fetch Script",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1140,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Spreadsheet File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        -840,
        180
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Client_Id != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region",
      "type": "n8n-nodes-base.function",
      "position": [
        -640,
        100
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        -440,
        340
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "Delivered",
              "value": "NO"
            },
            {
              "name": "FileName",
              "value": "={{$node[\"Spreadsheet File\"].parameter[\"operation\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -760,
        580
      ]
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Country_Region != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region3",
      "type": "n8n-nodes-base.function",
      "position": [
        -140,
        160
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://localhost:8080/items/dummy",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={\n\"Country_Region\":\"{{$node[\"Filter region3\"].json[\"Country_Region\"]}}\",\n\"Last_Update\":\"{{$node[\"Filter region3\"].json[\"Last_Update\"]}}\"\n}",
        "headerParametersJson": "={\n\"Authorization\": \"Bearer {{$node[\"HTTP Request1\"].json[\"data\"][\"access_token\"]}}\",\n\n\"Content-Type\" : \"application/json\"\n}"
      },
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        60,
        520
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "functionCode": "\nconst date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split(\"T\")[0].split(\"-\");\nitem.date = `${date[1]}-${date[2]}-${date[0]}`;\nreturn item;"
      },
      "name": "Get Date",
      "type": "n8n-nodes-base.functionItem",
      "position": [
        -1440,
        320
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        -1640,
        180
      ]
    }
  ],
  "connections": {
    "Fetch Script": {
      "main": [
        [
          {
            "node": "Spreadsheet File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File": {
      "main": [
        [
          {
            "node": "Filter region",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter region": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Filter region3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter region3": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Date": {
      "main": [
        [
          {
            "node": "Fetch Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Get Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Can someone help here

Sorry for delay, could you please paste workflow following this instruction:

I am not able to paste this workflow to my n8n ;/

Thanks for your response. I made few changes. Tried paste in another n8n instance it was working. Hope it will work for you now

{
  "nodes": [
    {
      "parameters": {
        "url": "=https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{{$json[\"date\"]}}.csv",
        "responseFormat": "file",
        "options": {},
        "headerParametersUi": {
          "parameter": []
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "Fetch Script1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Spreadsheet File1",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        1180,
        180
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Client_Id != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region1",
      "type": "n8n-nodes-base.function",
      "position": [
        1460,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        1680,
        200
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "Delivered",
              "value": "NO"
            },
            {
              "name": "FileName",
              "value": "={{$node[\"Spreadsheet File1\"].parameter[\"operation\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1340,
        580
      ]
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Country_Region != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region4",
      "type": "n8n-nodes-base.function",
      "position": [
        1940,
        200
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "customurl",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={\n\"Country_Region\":\"{{$node[\"Filter region4\"].json[\"Country_Region\"]}}\",\n\"Last_Update\":\"{{$node[\"Filter region4\"].json[\"Last_Update\"]}}\"\n}",
        "headerParametersJson": "={\n\"Authorization\": \"Bearer {{$node[\"HTTP Request1\"].json[\"data\"][\"access_token\"]}}\",\n\n\"Content-Type\" : \"application/json\"\n}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2160,
        200
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "functionCode": "\nconst date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split(\"T\")[0].split(\"-\");\nitem.date = `${date[1]}-${date[2]}-${date[0]}`;\nreturn item;"
      },
      "name": "Get Date1",
      "type": "n8n-nodes-base.functionItem",
      "position": [
        660,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "name": "Cron1",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        460,
        180
      ]
    }
  ],
  "connections": {
    "Fetch Script1": {
      "main": [
        [
          {
            "node": "Spreadsheet File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File1": {
      "main": [
        [
          {
            "node": "Filter region1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter region1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Filter region4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter region4": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Date1": {
      "main": [
        [
          {
            "node": "Fetch Script1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron1": {
      "main": [
        [
          {
            "node": "Get Date1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hey @Priya_Kumar

I am not sure what you are struggling with, I cannot run filter because of 413 error, but this should work for you

{
  "nodes": [
    {
      "parameters": {
        "url": "=https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{{$json[\"date\"]}}.csv",
        "responseFormat": "file",
        "options": {},
        "headerParametersUi": {
          "parameter": []
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "Fetch Script",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1400,
        900
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Spreadsheet File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        -1120,
        900
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Client_Id != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region",
      "type": "n8n-nodes-base.function",
      "position": [
        -900,
        900
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        -720,
        920
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "Delivered",
              "value": "NO"
            },
            {
              "name": "FileName",
              "value": "={{$node[\"Spreadsheet File\"].parameter[\"operation\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -900,
        1080
      ]
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Country_Region != \"NULL\")\n// return bills.json;\nreturn items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");"
      },
      "name": "Filter region3",
      "type": "n8n-nodes-base.function",
      "position": [
        -460,
        1080
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://localhost:8080/items/dummy",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={\n\"Country_Region\":\"{{$node[\"Filter region\"].json[\"Country_Region\"]}}\",\n\"Last_Update\":\"{{$json['Last_Update']}}\"\n}"
      },
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -180,
        920
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "functionCode": "\nconst date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split(\"T\")[0].split(\"-\");\nitem.date = `${date[1]}-${date[2]}-${date[0]}`;\nreturn item;"
      },
      "name": "Get Date",
      "type": "n8n-nodes-base.functionItem",
      "position": [
        -1700,
        900
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "name": "Cron2",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        -1920,
        900
      ]
    }
  ],
  "connections": {
    "Fetch Script": {
      "main": [
        [
          {
            "node": "Spreadsheet File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File": {
      "main": [
        [
          {
            "node": "Filter region",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter region": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Filter region3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter region3": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Date": {
      "main": [
        [
          {
            "node": "Fetch Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron2": {
      "main": [
        [
          {
            "node": "Get Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

image

Please let me know if I can help more

my problem is
spread sheet output is array of JSON with multiple objects but the current workflow makes HTTP post only with first json object. I need guidance how can post complete json array

Check this out, is it what you need?

{
  "nodes": [
    {
      "parameters": {
        "url": "=https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{{$json[\"date\"]}}.csv",
        "responseFormat": "file",
        "options": {},
        "headerParametersUi": {
          "parameter": []
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "Fetch Script",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1640,
        680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Spreadsheet File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        -1360,
        680
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Client_Id != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region",
      "type": "n8n-nodes-base.function",
      "position": [
        -1140,
        680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        -960,
        700
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "Delivered",
              "value": "NO"
            },
            {
              "name": "FileName",
              "value": "={{$node[\"Spreadsheet File\"].parameter[\"operation\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -1140,
        860
      ]
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\n// const bills= {}\n// bills.json = {}\n// bills.json = items.filter(item => item.json.Country_Region != \"NULL\")\n// return bills.json;\n// return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\nlet regions = []\nlet updates = []\n\nfor(item of items){\n  regions.push(item.json.Country_Region)\n  updates.push(item.json.Last_Update)\n}\n\nreturn [\n  {\n    \"json\": {\n      \"regions\": regions,\n      \"updates\": updates\n    }\n  }\n]"
      },
      "name": "Filter region3",
      "type": "n8n-nodes-base.function",
      "position": [
        -700,
        860
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://localhost:8080/items/dummy",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={\n\"Country_Region\":\"{{$json['regions']}}\",\n\"Last_Update\":\"{{$json['updates']}}\"\n}"
      },
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -420,
        700
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "functionCode": "\nconst date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split(\"T\")[0].split(\"-\");\nitem.date = `${date[1]}-${date[2]}-${date[0]}`;\nreturn item;"
      },
      "name": "Get Date",
      "type": "n8n-nodes-base.functionItem",
      "position": [
        -1940,
        680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "name": "Cron2",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        -2160,
        680
      ]
    }
  ],
  "connections": {
    "Fetch Script": {
      "main": [
        [
          {
            "node": "Spreadsheet File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File": {
      "main": [
        [
          {
            "node": "Filter region",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter region": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Filter region3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter region3": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Date": {
      "main": [
        [
          {
            "node": "Fetch Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron2": {
      "main": [
        [
          {
            "node": "Get Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
{
  "nodes": [
    {
      "parameters": {
        "url": "=https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{{$json[\"date\"]}}.csv",
        "responseFormat": "file",
        "options": {},
        "headerParametersUi": {
          "parameter": []
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "Fetch Script1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Spreadsheet File1",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        1180,
        180
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Client_Id != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region1",
      "type": "n8n-nodes-base.function",
      "position": [
        1460,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        1680,
        200
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "Delivered",
              "value": "NO"
            },
            {
              "name": "FileName",
              "value": "={{$node[\"Spreadsheet File1\"].parameter[\"operation\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1340,
        580
      ]
    },
    {
      "parameters": {
        "functionCode": "//items[0].json.myVariable = 1;\nconst bills= {}\nbills.json = {}\nbills.json = items.filter(item => item.json.Country_Region != \"NULL\")\nreturn bills.json;\n//return items.filter(item => item.json.Combined_Key == \"Berlin, Germany\");\n\n"
      },
      "name": "Filter region4",
      "type": "n8n-nodes-base.function",
      "position": [
        1940,
        200
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "customurl",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={\n\"Country_Region\":\"{{$node[\"Filter region4\"].json[\"Country_Region\"]}}\",\n\"Last_Update\":\"{{$node[\"Filter region4\"].json[\"Last_Update\"]}}\"\n}",
        "headerParametersJson": "={\n\"Authorization\": \"Bearer {{$node[\"HTTP Request1\"].json[\"data\"][\"access_token\"]}}\",\n\n\"Content-Type\" : \"application/json\"\n}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2160,
        200
      ],
      "typeVersion": 1,
      "retryOnFail": true,
      "maxTries": 5
    },
    {
      "parameters": {
        "functionCode": "\nconst date = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split(\"T\")[0].split(\"-\");\nitem.date = `${date[1]}-${date[2]}-${date[0]}`;\nreturn item;"
      },
      "name": "Get Date1",
      "type": "n8n-nodes-base.functionItem",
      "position": [
        660,
        180
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "name": "Cron1",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        460,
        180
      ]
    }
  ],
  "connections": {
    "Fetch Script1": {
      "main": [
        [
          {
            "node": "Spreadsheet File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File1": {
      "main": [
        [
          {
            "node": "Filter region1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter region1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Filter region4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter region4": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Date1": {
      "main": [
        [
          {
            "node": "Fetch Script1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron1": {
      "main": [
        [
          {
            "node": "Get Date1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks. I want to multiple calls for each JSON object

example if spread sheet returns below 3 objects then I want to fire 1 HTTP call /Json Object. it means Http call will happen 3 times with {{ $item(“0”).$node[“Spreadsheet File1”].json }} , {{ $item(“1”).$node[“Spreadsheet File1”].json }} and {{ $item(“3”).$node[“Spreadsheet File1”].json }}.

there can be more than 3 objects so it has to make a http call based on the spreadsheet output.

[
{
"Country_Region": "Afghanistan",
"Last_Update": 44563.18115740741,
"Lat": 33.93911,
"Long_": 67.709953,
"Confirmed": 158107,
"Deaths": 7356,
"Combined_Key": "Afghanistan",
"Incident_Rate": 406.1488261213084,
"Case_Fatality_Ratio": 4.652545428096163
},
{
"Country_Region": "Albania",
"Last_Update": 44563.18115740741,
"Lat": 41.1533,
"Long_": 20.1683,
"Confirmed": 210224,
"Deaths": 3217,
"Combined_Key": "Albania",
"Incident_Rate": 7305.024671624156,
"Case_Fatality_Ratio": 1.5302724712687419
},
{
"Country_Region": "Algeria",
"Last_Update": 44563.18115740741,
"Lat": 28.0339,
"Long_": 1.6596,
"Confirmed": 218818,
"Deaths": 6284,
"Combined_Key": "Algeria",
"Incident_Rate": 499.00295416006406,
"Case_Fatality_Ratio": 2.871792996919815
},

Solution. I was missing basic knowledge on n8n when I posted this. Each n8n iterates the JSON object if the response comes from the previous node as an object. No need to create the loop.

1 Like

This is true for most of nodes, happy it’s working!

1 Like