Google Sheets create New Sheet with Every Item

I am reading a sheet and getting array of objects from it. Next, I want to create a new sheet with each item But it works with only the first item then I get this error. Please see screenshots below. Why it doesn’t work for each item?


Here is the data I’m working with

And the error

{“message”:“404 - {“error”:{“code”:404,“message”:“Requested entity was not found.”,“status”:“NOT_FOUND”}}”,“name”:“Error”,“stack”:“Error: Request failed with status code 404\n at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n at IncomingMessage.emit (events.js:327:22)\n at endReadableNT (internal/streams/readable.js:1327:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)”}

NodeApiError: The resource you are requesting could not be found
    at Object.googleApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GenericFunctions.js:43:15)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GoogleSheets.node.js:1021:40)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:447:47

Hi @burakyccl, is there a chance you are using an expression like {{$node["Webhook1"].json...}} to populate the spreadsheet ID field in your screenshot? Such an expression would look up an item using the current index.

So for the first item of the Google Sheets node it would look at the first item from your other node to find a Spreadsheet ID. For the second item it would look at the second item from your Webhook1 node which most likely only has one item.

If that’s the case you could put $item(0) in front of your expression, so {{$item(0).$node["Webhook1"].json...}}. This would always reference the first item from your webhook node and is explained in more detail here.

1 Like

I can’t thank you enough. You made my day. Adding $item(0) to expression solved it. Have a nice day :heart:

1 Like

Awesome, I am glad to hear this worked out! Thanks so much for confirming :slight_smile:

1 Like