Http-request sending files gives "the item has no binary field

Describe the problem/error/question

I’m trying to upload a binary file (pdf) to harvest.
Since the provided interface does not support this (yet?), I’m using ‘HTTP-Request’.
I’ve captured the binary file (a pdf) from an incoming email (IMAP).

What is the error message (if any)?

I receive the error message: “The item has no binary field ‘[object Object]’ [item 0]”

As shown in the screenshot, the node input has a binary called “attachment_0”.
In the field ‘Input Data Field Name’ I’ve tried an expression shown in the screenshot. In the screenshot, it is visible that the expression does result in the binary object.

I’ve also tried the fixed value “attachment_0” which also gives me an error message.

Can somebody tell me what I’m doing wrong?

Please share your workflow

Information on your n8n setup

  • n8n version: 1.39.1 (self hosted)
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system: Ubuntu

The second version is the right way to do it.
It’s probably something simple.
Can you try attachment[0]

Thanks for the quick reply @atwork1

I’ve tried your suggestion but that didn’t work.
image

Then I did some more debugging.

At point 1 in the screenshot below, I also read the content of the binary file. Here I’m using “attachment_0” and this works.
I’ve duplicated that node and moved it to points 2 and 3.
The duplicated node at point 2 works.
The duplicated node at point 3 gives me the same error message.

By the looks of it, it seems like the merge node is causing the issue. Although in the debugger, the binary is visible as output from the node “Merge1”.

In the variant with “attachment_1” it said item 1 is missing the binary, that suggests that it worked for item 0 and item 1 simply has no binary . (I missed that earlier)

You need to do a different merge. Append appends the item that has no binary.

See here a screenshot from the merge step.


The input has 1 item, the output has 2 items. But I think (and correct me if I’m wrong) this refers to the items in the json object.


If I look at the binary for both input and output, it seems to be there.

I’ve got it to work, but I don’t know why…

I’ve added an “Aggregate” node which passes all the data into a single list called “data”. And set the option to include binaries.

image

Now the binary with the same name “attachment_0” is found and the workflow executes as wanted.

Happy if somebody can shine some light on this :slight_smile:

2 Likes

each item has a json part and a binary part.
th issue is, that for the second item the node expects a binary object named “attachment_0” but the binary object is empty or undefined.

a neat trick to see the results for different items, is to switch the input view to table.
when you mouse-over the different rows it will show the results for each item.

instead of the aggregate node you could have changed the merge node to:

“combine” → merge by position (or merge by field if theres a correlation)
“choose branch” → select the input with the binary

be aware, that if the Workflow has multiple items as input it will fail in production, the way you set it up now, because it will only work for the first item.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.