The problem is: You receive all attachments from trigger nodes, such as GMail, in one item, but you need them in several items in order to be able to perform an action for each attachment.
Solution: Use Iterate Code nodes to place the binary objects in individual items.
What is the error message (if any)?
Error: ‘The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined’
Please share your workflow
Information on your n8n setup
n8n version: 1.79.3
Database (default: SQLite): SQLite
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
I wasn’t able to test your HTTP Request node because I don’t have access to the API.
But I could receive the binary files from GMail.
By the way… pinning the files not always work. Make sure you are actually seing the binary files instead of only JSON, ok?
But there’s one silly thing that sometimes makes a difference:
Some APIs are not well built and are very picky with URL paths.
Once I was able to make an endpoint work by adding a slash at the end of the URL.
Like this: https://api.lexoffice.io/v1/files/
Instead of this: https://api.lexoffice.io/v1/files
Other than that I really don’t have any idea of what is wrong with that request.
I checked the documentation and it looks exaclty like it is instructed.
Your point about pinned/unpinned data is something I have already registered and worked around my tests by asking for a specific mail on each execution, or just doing ‘Read File’ from my machine. Because yes, binary with X objects is displayed, as here:
If I enter this output in the HTTP node (whether with or without / at the end) and define the value ‘attachment_0’ in HARD → it works. If I then set HARD to the value ‘attachment_1’, it also works So my thought was → let us automate this with use of your code to split the files into X items and, if necessary, pass them to the HTTP node with or without a loop node around the HTTP node.
But yes, this exactly throws then the error mentioned at the top.
Regarding your point about talking to LexOffice: I did, they said they don’t support custom coding (which this is). They only offer support for official partners like Zapier. Your statement remains: This problem is related to my custom software.
With this error picture, I can disagree less.
What I am currently trying to programme, but just can’t do it, is: I take the number of binary objects and start a workflow/loop correspondingly often. In the first run I execute the call with ‘attachment_0’, in the second ‘attachment_1’ and so on (The way I do it manually). - This does not mean packing the binary items one below the other, only using the ‘GMail Trigger’ structure X times and only swapping the attachment_X value.
@solomon There is some issue in n8n. I tried now all with n8n own API. So I created a second workflow with just a webhook node on “POST”. Then I combined it with my test I mentioned to “loop from left to right”, instead of looping item by item.
Check this out:
The question now is whether it is an error in n8n or the code snippet from you. Such threads may also indicate a ‘buffer’ error.
Oooh nice catch! Probably a problem with the code, then!!
Can you try sending a file to LexOffice using that method that worked?
Skipping the Code node
I have now made a screencast of my current test workflow, which you can certainly replicate quickly for your tests. In the video, I only run ‘gmail + HTTP Call’ and ‘gmail + Code + HTTP Call’ and that’s the only time the problem appears.
As an alternative to the gmail node, you can also use a ‘Read Files’ node, which has the same result. (What my “shit” solution will be is gmail → write file and then read file → api call)