# Http request Update image with binary file - different behaviour vs postman

**URL:** <https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241>\
**Category:** Questions\
**Tags:** node\
**Created:** [August 12, 2021, 12:38pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241 "2021-08-12T12:38:27Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 12:38pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/1 "2021-08-12T12:38:27Z")

</div>

hi all, akeneo again…  
i try to update a product image, hers is the doc

#### REQUEST

POST /api/rest/v1/media-files

##### Path parameters

##### Query parameters

##### Headers

`Authorization` • Equal to ‘Bearer xxx’, `xxx` being the authentication token, see [Authentication](https://api.akeneo.com/documentation/authentication.html) section  
`Content-type` • Equal to ‘multipart/form-data’, no other value allowed

##### Body

Given as form-data  
`product` _(string )_ • The product to which the media file will be associated. It is a JSON string that follows this format ‘{“identifier”:“product\_identifier”, “attribute”:“attribute\_code”, “scope”:“channel\_code”,“locale”:“locale\_code”}’.

 

`file` _(string / binary)_ • The binaries of the file

ok, i did it in postman, it works

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

Then i try with n8n  
i got a file by requesting an url

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

set a http request like postman an use $node[“HTTP Request”].binary.data for file value

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

But i got this error :  
ERROR: source.on is not a function

thanks for help

```
{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://pim-poc.coreplighting.net/api/rest/v1/media-files",
        "options": {
          "bodyContentType": "multipart-form-data"
        },
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "product",
              "value": "{\"identifier\":\"10627329\", \"attribute\":\"picture\", \"scope\":null,\"locale\":null}"
            },
            {
              "name": "file",
              "value": "={{$node[\"HTTP Request\"].binary.data}}"
            }
          ]
        },
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$node[\"Pim Produit Tokens\"].json[\"tokenwrite\"]}}"
            },
            {
              "name": "Content-Type",
              "value": "multipart/form-data"
            }
          ]
        }
      },
      "name": "PIMPOC write Product media file1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        400,
        240
      ]
    },
    {
      "parameters": {
        "url": "https://somewhere.jpg",
        "responseFormat": "file",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        180,
        240
      ]
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "PIMPOC write Product media file1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [August 12, 2021, 12:43pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/2 "2021-08-12T12:43:30Z")

</div>

Hey @Christel_Doudet,

You don’t need to pass expression for the file. Can you try by simply passing data in the _ **Value** _ field?

---

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 12:47pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/3 "2021-08-12T12:47:44Z")

</div>

hi @harshil1712 ,  
{  
“name”: “file”,  
“value”: “={{$node[“HTTP Request”].binary.data}}”  
}  
i don’t understand, what did you mean by simply passing data. It’s not what i have done ?

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [August 12, 2021, 12:50pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/4 "2021-08-12T12:50:59Z")

</div>

I’ve updated your example workflow. You can see that I am not using the expression `{{$node[“HTTP Request”].binary.data}}`, but passing `data` instead.

---

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 12:59pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/5 "2021-08-12T12:59:37Z")

</div>

@harshil1712 , data means what ? just the word “data”  
here is the error:

```
{
    "code": 422,
    "message": "Property \"file\" is required."
}

```

The same as in postman if i replace the file by text “data”

how can “data” can refer to the binary file get by url ?

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [August 12, 2021, 1:16pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/6 "2021-08-12T13:16:27Z")

</div>

@Christel_Doudet, in n8n, you refer to a file with the keyword `data`. If you observe your first HTTP Request that fetches the file, the file has keyword data. In n8n, whenever you want to refer to a file you use that keyword. You can also use a different keyword if you update that field.

Is there a node between these two nodes? You need to make sure that the binary file is accessible by the node

---

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 1:22pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/7 "2021-08-12T13:22:13Z")

</div>

No nodes between, @harshil1712

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

---

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 1:58pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/8 "2021-08-12T13:58:20Z")

</div>

@harshil1712 , data was just interpreted as string

```
"formData": {
"product": "{"identifier":"10627329", "attribute":"picture", "scope":null,"locale":null}",
"file": "data"
},

```

May be sometihing is missing in http request setting ?

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [August 12, 2021, 3:09pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/9 "2021-08-12T15:09:49Z")

</div>

Looking at their API documentation, they have mentioned that the file can have either a string or binary value. I am not sure what we are missing. Maybe @RicardoE105 can help out

---

<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:** [August 12, 2021, 3:30pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/10 "2021-08-12T15:30:53Z")

</div>

The node it’s not setup correctly. Check the image below. Keep in mind the HTTP node has the limitation where you can either send binary data or JSON when sending multipart-form-data. Meaning, the example where you send the product and the file at the same time it’s not possible. You have to send one and then the other one. Assuming of course, the API you consuming supports it.

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

---

<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:** [August 12, 2021, 3:34pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/11 "2021-08-12T15:34:21Z")

</div>

This limitation it’s going to be addressed in the v2 of the HTTP node.

---

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 3:35pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/12 "2021-08-12T15:35:48Z")

</div>

ok, do you have a due date for this ?

---

<div class="post-metadata">

**Author:** ![Christel\_Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel_doudet/32/5198_2.png) [@Christel\_Doudet](https://community.n8n.io/u/Christel_Doudet)\
**Post date:** [August 12, 2021, 4:05pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/13 "2021-08-12T16:05:09Z")

</div>

Bad news, i can’t send the file alone, product info is needed.  
How can i deal with this,?  
can i call a js script with parameter wich can do the job ?

---

<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:** [August 12, 2021, 4:20pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/14 "2021-08-12T16:20:47Z")

</div>

You can make the HTTP request from a function node instead. Check the posts below.

> [@HTTP Request GET with body](http://community.n8n.io/t/http-request-get-with-body/6249/2):
>
> Welcome to the community @Lucas_Couto I would make the HTTP request from a function node instead. By default, requiring packages it’s not allowed, but you can enable it by setting env variables below: export NODE\_FUNCTION\_ALLOW\_BUILTIN=util export NODE\_FUNCTION\_ALLOW\_EXTERNAL=request After that, to make a GET request, you can do something similar to: const request = require('request') const { promisify } = require('util'); const rq = promisify(request); const data = await rq({ uri: "htt…

> [@Upload File: Multipart-formdata](http://community.n8n.io/t/upload-file-multipart-formdata/1543/7):
>
> Thanks @RicardoE105 Yes I defined axios as follows: docker run -it --rm --name n8n -p 5678:5678 -e NODE\_FUNCTION\_ALLOW\_EXTERNAL=axios,request-promise-native,form-data,fs,request -v ~/.n8n:/root/.n8n n8nio/n8n n8n start --tunnel It still fails though not with a complaint about axios, but in the sample code below, even the echo service does not reach the console.log for success or error. const axios = require('axios'); (async () =\> { try { const response = await axios.get('htt…

---

<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:** [August 12, 2021, 4:22pm UTC](https://community.n8n.io/t/http-request-update-image-with-binary-file-different-behaviour-vs-postman/7241/15 "2021-08-12T16:22:44Z")

</div>

Sadly, we do not have at the time.
