NodeOperationError: No binary data property "fileName" does not exists on item!

I am trying to upload a file via a HTTP POST request.

image

here is the file creation

here is the failed upload

The site needs to have:
attachment=data
filename=xxxxx

as part of the upload

after trial and error attachment:data,filename:xxxxx seems to be what it needs but it can never read file name

I’ve tried

binary.data.fileName
data.fileName
fileName
ioc.csv

.data.fileName
.fileName

etc.

now i have no idea why the filename part isn’t working? any ideas?

here is the curl request I have as a reference, the auth and etc is all sorted and no issue.

curl --request POST -F"[email protected]<file_directory>/<file_name>" -F
"filename=<file_name>"
"https://xxxxxx/api/v1/xxxxx/xxxxx/attachment/" -H 'Authorization: apikey <username>:<api_key>' -v

Hi @RedPacketSec

The filename it self you want to use on that data binary file?
Usually when you sent a file it will just take the filename as well. so you only need to give the binary property which is “data” in your case. Possible with “attachment:data” like you did.
The api should accept that no problem.
If this does not work, do you have some API doc to give us more info?

it doesnt accept data alone , it says missing filename

"status": "rejected",
"reason": {
"message": "400 - {"message":"Missing required field \"filename\""}",
"name": "Error",

Ah Sorry, might have missed that in the original post.

I think there was an issue with sending file data and also other fields in the same request using “form-data multipart”
If I remember correctly. @MutedJam can you confirm or deny that?

I think there was an issue with sending file data and also other fields in the same request using “form-data multipart”

I am afraid so, that’s not currently supported by the HTTP Request node and you would need to write some JS code for this. @iamoshiro posted a great code snippet a while back over here: Help for the noob to upload a file using function node (it’s failing for the service used in that post, but don’t let that fool you, it actually gets the job done nicely). Here’s a quick example workflow downloading a file and then uploading it via the Function node:

Both the file and other form values arrive as expected:

2 Likes

i’ll give it a go, please can you fix the http request node so we dont need to use a function node to do this

I think this is actually planned for the next version of the HTTP Request node :slight_smile:

well let me know when thats done and i’ll test it

Nice, then I can copy the implementation.
I couldn’t get it to work on a custom node either, didn’t look too deep into it. (of course, copy-pasting implementations of current nodes) :slight_smile:

1 Like

that code sample means i now need to import a new requirement that i currently dont have
“request-promise-native”

This is an awful faf for being able to provide a simple filename :frowning:

This works fine in a workflow, but I think it’s not recommended to use in nodes :see_no_evil:

This page says “use the built in request library”, though it also says this would lead to request-promise-native being used which is outdated I think (an update for the node building section of our documentation is coming though).

All that said, it would most likely work and I might have done it before for my own custom node :wink:

1 Like

It’s included in n8n, but you might need to allow it via the NODE_FUNCTION_ALLOW_EXTERNAL environment variable.

ill have a go see how i get on.

Can you try to make the HTTP node a priority as anyone that is unable to use an offical node falls back to using the HTTP node to do all sorts of API calls, and if this node isnt allowing us to do stuff and we have to fall back to javascript function nodes and importing libraries its going to cause an issue for people like myself that are advanced and totally scare new kids on the block away from using the platform… in my view the HTTP node needs to be the cornerstone of the platform that can handle ANYTHING the other nodes are not able to do… :wink:

Tbh I don’t know how much of a priority the next version of the HTTP Request currently is, but maybe @RicardoE105 knows more?

I needed it for the node that goes with my own application. So I just made a simple request to add in the other fields after. So it now does an upload of the file and then a request to fill in the specs for that file. Had to make that endpoint anyways so just did it sooner and used it as well for the first time creation of a file. :slight_smile:

1 Like

well I’ve just accepted that I am not going to be able to upload the file and will have to think of something else. The function node way is just not something i want to pursue as i will have to hand these flows over to other people at some point and that adds way to much complexity.

Hi @RedPacketSec

You could create your own “API” by using webhooks.
So webhook → function → webhook response.
This way you can have others use that webhook if needed. And of course use it your self as well. :wink:

It will need you to setup that function node correctly once though, so that’s still a bit of a bummer.

We already have a design for the HTTP V2, and we are starting to work on it soon. It will address all issues known so far, plus include improvements like allowing you to configure the node from a curl command.

1 Like