# Trying to upload a file to an HTTP endpoint

**URL:** <https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459>\
**Category:** Questions\
**Created:** [February 23, 2021, 12:09pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459 "2021-02-23T12:09:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Veer\_Manhas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/veer_manhas/32/3427_2.png) [@Veer\_Manhas](https://community.n8n.io/u/Veer_Manhas)\
**Post date:** [February 23, 2021, 12:09pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/1 "2021-02-23T12:09:00Z")

</div>

I have the request that has to be made which I am able to make from Postman but am unsuccessful in doing from HTTP node.

I looked at this and was trying to send it as binary:  
[Webhook to HTTP request - #4 by jan](http://community.n8n.io/t/webhook-to-http-request/2983/4) but was unsuccessful. I am getting an error that the endpoint isn’t getting any file from the request.

```
curl --location --request POST 'https://endpoint.something.com/upload' \
--header 'Authorization: something' \
--form 'file=@"record.csv"' \
--form 'user_email="test@email.com"' \
--form 'recipe_slug="recipe_slug_test"'

```

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/6/673185b88e80c176a457c78ba9ca1571f885c11e.png)

I am using Binary \> data from the HTTP node after downloading the file.

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/e/ead5c1487678348178a5e9c384e5ffea455402a2.png)

I think I might be missing something really small.

Thanks

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [February 23, 2021, 3:23pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/2 "2021-02-23T15:23:46Z")

</div>

When using multipart/form-data in the HTTP Node you can just send either binary data or key-value pairs in the body. Does the API allow you to upload the file first and later update the record with the `user_email` and `recipe_slug `?

If so, then you can update the file first by setting up the HTTP node as follow:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/c/c7f0a2bc71c6e187ab75b9233b37c6533a6e3b60.png)

and then, with the Record ID, you can make probably a PUT with the `user_email` and `recipe_slug` in the body.

---

<div class="post-metadata">

**Author:** ![Veer\_Manhas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/veer_manhas/32/3427_2.png) [@Veer\_Manhas](https://community.n8n.io/u/Veer_Manhas)\
**Post date:** [February 24, 2021, 11:22am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/3 "2021-02-24T11:22:39Z")

</div>

> [@RicardoE105](#):
>
> I allow you to uplo

Unfortunately, it doesn’t allow for that. I will write a function node to do so and see if I can access the internet from the function node.

---

<div class="post-metadata">

**Author:** ![Veer\_Manhas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/veer_manhas/32/3427_2.png) [@Veer\_Manhas](https://community.n8n.io/u/Veer_Manhas)\
**Post date:** [February 25, 2021, 5:11pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/4 "2021-02-25T17:11:47Z")

</div>

Do you think there might be workaround possible for this? We are moving away from Zapier and this is a blocker for a few scenarios.

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [February 26, 2021, 1:53am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/5 "2021-02-26T01:53:55Z")

</div>

ah yes, you can use a function node and make the HTTP Request from there. This works as long as you are self-hosting.

Set the env variable `export NODE_FUNCTION_ALLOW_BUILTIN=request-promise-native`

then in the function node, require the request module and made the HTTP Request using multipart/form-data. If you need help with the function node let me know.

You can check the post below as well.

> [@Upload File: Multipart-formdata](http://community.n8n.io/t/upload-file-multipart-formdata/1543/4):
>
> Nice idea @Kirst , just tested it and yes. Check the example below. Keep in mind that in order to require an NPM package on the function node you have to set an env variable. By default require a module is not allowed. In the example, I used the request-promise-native module and told N8N to use it like this export NODE\_FUNCTION\_ALLOW\_BUILTIN=request-promise-native. More info about that [here](https://docs.n8n.io/#/configuration?id=use-built-in-and-external-modules-in-function-nodes). { "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start"…

---

<div class="post-metadata">

**Author:** ![Veer\_Manhas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/veer_manhas/32/3427_2.png) [@Veer\_Manhas](https://community.n8n.io/u/Veer_Manhas)\
**Post date:** [March 1, 2021, 10:58am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/6 "2021-03-01T10:58:13Z")

</div>

I tried using axios with export and getting this error:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/d/d1d242f9136631de82da7355b74804e81a47ad57.png)

![image](https://europe1.discourse-cdn.com/n8n/original/2X/c/c94b63317e27dd7603f147291ec49653f00c7f37.png)

Is this not the correct way of using export in the function node?

---

<div class="post-metadata">

**Author:** ![shrey-42](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shrey-42/32/3437_2.png) [@shrey-42](https://community.n8n.io/u/shrey-42)\
**Post date:** [March 1, 2021, 11:11am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/7 "2021-03-01T11:11:47Z")

</div>

@Veer_Manhas The export option needs to be set via CLI (in npm based setup) or .env file (in Docker based setup), after installation of the node modules, appropriately, that need to be exported.

See:

> **[Configuration methods | n8n Docs](https://docs.n8n.io/hosting/configuration/configuration-methods/)**
>
> How to set environment variables for n8n.

---

<div class="post-metadata">

**Author:** ![Veer\_Manhas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/veer_manhas/32/3427_2.png) [@Veer\_Manhas](https://community.n8n.io/u/Veer_Manhas)\
**Post date:** [March 1, 2021, 11:13am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/8 "2021-03-01T11:13:48Z")

</div>

Thanks! This helps. Very new to n8n.

---

<div class="post-metadata">

**Author:** ![Veer\_Manhas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/veer_manhas/32/3427_2.png) [@Veer\_Manhas](https://community.n8n.io/u/Veer_Manhas)\
**Post date:** [March 4, 2021, 6:06pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/9 "2021-03-04T18:06:14Z")

</div>

Did that and tried AXIOS to call the API endpoint. I have to wait and then return data but for some reason n8n is saying

ERROR: No data got returned. Always return an Array of items!

```auto
var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('file', fs.createReadStream('3eVqeBxtm/recLKtWD7SpurvZwP (1).csv'));
data.append('user_email', 'email@email.com);
data.append('recipe_slug', 'recipe_slug_test');

var config = {
  method: 'post',
  url: 'https://endpoint.api',
  headers: { 
    'Authorization': 'auth-code', 
    ...data.getHeaders()
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
  let respData = [];
  respData.push(response.data);
  return respData;
})
.catch(function (error) {
  console.log(error);
});

```

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [March 4, 2021, 7:18pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/10 "2021-03-04T19:18:30Z")

</div>

Yes, because by the time the request finishes the function already returned. You might want to do something like below instead.

```
const response = await axios(config)
return [
    {
       json: response.data
   }
]
```

---

<div class="post-metadata">

**Author:** ![fishnux](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fishnux/32/16661_2.png) [@fishnux](https://community.n8n.io/u/fishnux)\
**Post date:** [March 29, 2022, 10:34am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/11 "2022-03-29T10:34:25Z")

</div>

Hi,

I’m not seeing the Send Binary Data option - was it removed?

 ![Screenshot](https://europe1.discourse-cdn.com/n8n/original/2X/d/d9a39a549d911d9a7da352dd00549d7b3132c5f8.png)

P.S.: I confirm the method is set to POST

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [March 30, 2022, 12:37am UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/12 "2022-03-30T00:37:17Z")

</div>

Yo have to set JSON/RAW Parameters to true.

---

<div class="post-metadata">

**Author:** ![syadnom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/syadnom/32/30830_2.png) [@syadnom](https://community.n8n.io/u/syadnom)\
**Post date:** [April 5, 2024, 8:01pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/13 "2024-04-05T20:01:30Z")

</div>

I’m looking for a similar enough solution, however my HTTP node doesn’t have ‘form-data mu’ in the body content or options etc. basically none of this node is there. I’m on the cloud instance so some version changes have happened. It seems like this http node has lost features?

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [April 25, 2024, 10:05pm UTC](https://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/14 "2024-04-25T22:05:28Z")

</div>

You are getting the newest version of the HTTP node. You should be able to send form data as shown below.

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/f/0/f001909faccd116b66e9221ff59e436d04a88335.png)
