Uploading a file using multipart form data doesn't work

So I need to recreate this curl comment on the n8n HTTP request node
curl --location --request POST ‘https://api.publit.io/v1/files/create?%26api_test%3Dtrue%26=
–form ‘[email protected]“Leptiri.jpg”’
As I understand, this is the setup I should have with the nameKey:fileName as the binary property. But for some reason, the API kept returning an error request saying I missed the file parameter required in the API. Any help to point out the mistakes that I made?


Hi @lamelama, your request looks good to me and I don’t know why publit.io might throw the error you are seeing.

Could you test the upload against a URL provided by a service like https://webhook.site/ and check if the data structure arriving on the server matches what publit.io describes in their documentation?

Hi @MutedJam @lamelama

Isn’t it so that you do not need to put “file:” in front of the binary property?
So instead of “file:data” just put in “data”.
Will check later today, if you haven’t already.

Hi @BramKn, the syntax file:data is fine if you want to specify the file key.

image

Check out this example workflow:

It can’t hurt testing with just data though, it just didn’t make a difference when I tested this myself. The file arrived just fine:

Thanks @MutedJam
Learned something new :slight_smile:

1 Like

Still doesn’t explain the original issue unfortunately :smiley:

publit.io does seem to have a free plan though, so I hope I’ll find some time later this week to give this a go with the real thing causing the trouble here (unless @lamelama can figure it out first, of course).

1 Like

so I don’t think the request is the problem my request never arrived with a file instead just bunch of binaries.The file I’m trying to upload is sourced from the Drive Download Node & I tried uploading it back to google drive & it uploaded just fine.

Does the upload work fine if you use my example workflow to download a file?

If so, could you share the shortest possible example workflow using which you were able to reproduce the problem (simply select it on your n8n canvas, press Ctrl+C and then insert the code here on the forum)?

Also, did you set the File ID in your Google Drive node? It seems empty on your screenshot.

This is the simple download google drive file & upload to publitio function that reproduce the file required error. & I’ve tested other form of downloading file through the http request & tried uploading to Publitio & the webhook test & indeed they both arrived as a file. So it’s 100% a problem with the file. Do I need to do anything to convert my downloaded file from Drive?

ok so I’ve figured out I skipped the file name option which screwed up the file even though I was still able to view it inside the n8n editor. Now that I properly named my file & extension. It uploaded just fine. Thanks for the debugging help!
CleanShot 2022-07-12 at 16.02.25@2x

1 Like

Oh, that was simpler than expected in the end. Glad to hear this worked and thanks so much for confirming!

Hi, I would like to ask, what if the multipart needs more than one parameter, like this one:

In the form data there are two parameters “image_type” and “image”. How do I need to do this? I’ve tried many ways but it doesn’t work.

Hi @Jack_Ray, welcome to the community :tada:

This was only introduced recently, so in a first step make sure you’re running the latest version of n8n. Then, add a new HTTP Request node (don’t copy an existing one as this would keep the old version) including all parameters to your workflow. Here’s an example:

This workflow will send both an image and an image_type field to your API. This is how the request received by the server looks like:

Hope this helps!

Going forward, could you open a new forum topic for questions like this? Posts on old threads marked as solved are easily missed. Thank you so much!

1 Like

WOW, it’s cool! It work. Thanks very much!
But I found that when a network request is wrong for parameters etc, the error returned is not an api error response, but a stack error like this. This doesn’t seem very friendly for debugging.


And Is the interface in your screenshot some kind of packet grabber?

1 Like

You’re quite right about the missing error. I ran into the same problem the other day and have reported it internally (the error information used to be way more helpful in the past, so this looks like a newly introduced bug to me). Perhaps @sirdavidoff can confirm when this will be addressed?

As a workaround you could enable these two response options:

image

n8n should then show the full response even if you hit an error, which makes debugging way easier until this problem is fixed.

As for the tool from my screenshot that’s webhook.site, a service providing unique URLs to which you can send pretty much any HTTP Request for closer inspection.

1 Like

A couple of versions ago we changed how we clone the objects in n8n, which messed up how the errors are presented in the UI. That got fixed with [email protected] If the problem persists after that, @RicardoE105 will investigate further.

1 Like