Airtable Upload Files to Nextcloud Path Problem

Describe the issue/error/question

I’m pulling files from Airtable and upload them on Nextcloud.
I receive a folderpath in the initial webhook, where the files should be uploaded. This is working fine to the first item in the array I get from Airtable, but not the following ones. The following files are all uploaded to the base directory (in my case /xxx/). I do not understand why the workflow is not pulling the folder path from the webhook for file2, file3 etc. of the item list.

I tried the “set” module, but this also didn’t help.

The workflow will only upload the first file to the directory specified in the expression, but not file2, file3 etc.which is what I want.

I’m new to n8n, so please excuse if this is easy to solve.

Please share the workflow

Information on your n8n setup

  • n8n version:

Latest version

  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:

Docker

Hi @mabaker, welcome to the community :tada:

In a first step you would want to narrow down the problem. Look at the data returned by each node. You can probably see the problem starts on your Set node. This node uses an expression of {{$node["Webhook"].json["body"]["foldername"]}}.

Now for the first item this Set node receives it would look up the first item from the Webhook node and read the foldername field from the Webhook node. For the second incoming item it would then try and read foldername from the second item from your Webhook node which is presumably what fails here (same for the third, fourth and so on item).

To avoid this, you would want to use an expression like {{ $(item(0).$node["Webhook"].json["body"]["foldername"] }} This ensures that n8n always uses the first item (with index 0) of your Webhook node, even when processing additional items. $item(0) is documented here in more detail.

Hope this helps! Let me know if you run into any trouble with this.

Thank you! Happy to be here :slight_smile:

Oh, that is quite different from what I expected. But now that I’m reading about it, it becomes clear. Thank you, the solution worked.

1 Like

Glad to hear, thanks very much for confirming!