How do I put a file with the Http Request component?

Hi, I just got started with n8n. I’m trying to build a test workflow that reads a single file from Dropbox and then uses a HTTP PUT to send the file to another url.

The Dropbox component works fine and retrieves the file and stores it in a binary property called “data”. But I am unable to configure the Http Request component to upload the file.

Here’s what I have so far:

{
      "parameters": {
        "requestMethod": "PUT",
        "url": "http://host.docker.internal:9998/tika",
        "responseFormat": "string",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "raw"
        },
        "bodyParametersJson": "data"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        730,
        300
      ]
    }

This works, but it just uploads the string “data” instead of the contents of the file. I tried a bunch of other request settings but I haven’t been able to get it to work yet.

Sending a file to the service using “curl -T http://localhost:9998/tika” works fine so I know the service is running. I just need to reproduce exactly what curl does in n8n.

Is there documentation somewhere on how to upload files with the Http Request component? I feel like I’m overlooking something very simple. I could use a custom function but I feel the Http Request component should be able to do this.

Thanks!

First welcome to the community!
Yes, you are sadly right. The HTTP Request-Node does really not have the possibility right now to upload binary data. I will have a look and try to implement it. Will inform you once it is done and a new version with it got released.

Wow thanks!

Which workaround would you advise for me right now? Should I use a function instead?

Yes guess that is the only thing that is possible. With allowing access to the “request” module:
https://docs.n8n.io/#/configuration?id=use-built-in-and-external-modules-in-function-nodes

Ok programmed it and released with [email protected]

As the original node-design did not get planned with it in mind, it is sadly not the most obvious. Anyway, for now, it at least works. It can then get improved in future versions of the node. Here an example:

{
  "nodes": [
    {
      "parameters": {
        "authentication": "basicAuth",
        "requestMethod": "PUT",
        "url": "https://example.com/new-file-http.png",
        "responseFormat": "string",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "raw"
        },
        "sendBinaryData": true
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        600,
        300
      ],
      "credentials": {
        "httpBasicAuth": ""
      }
    },
    {
      "parameters": {
        "url": "https://cdn0.iconfinder.com/data/icons/infy-hand-drawn/512/idea-blub-512.png",
        "responseFormat": "file",
        "options": {}
      },
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        400,
        300
      ]
    }
  ],
  "connections": {
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks! I’ll upgrade my installation and try it out.

Great! Tell me if you have problems.

@mdfarragher does it work fine?