How to send binary via HTTP from non-parent node?

Hi. I’m doing a workfow where Telegram accepts an image, sends a “in process” message and then send the image to process.
image

The problem is that I can’t now tell the HTTP node to pick the “data” field for binaries. This is because the trigger node with the image is no longer the parent of the HTTP node.

So I need to tell the HTTP node somehow how to take the binaries using the expression, I guess. And I can’t find the way to do that — the binary data field is absent. The current choise doesn’t help:

What is the processing message node’s output? Specifically the binary tab?

would something like this work?


image

That might work. But have first to figure if the Processing Message node is passing the binary data or not. If it’s passing the data, you can reference the binary data in the HTTP node. Else something like what you suggested has to be done as we need to add the binary data to the output of the processing message.

It has no binaries
This is the first node:

This is the 2nd (with message):

@RedPacketSec I’ll try to check it.
But anyway, I guess that there must be a way to accept binary files from any node in the workflow, not from the strict parent only.

Then you can do what @RedPacketSec suggested but with the Merge by Index option. With that, the binary data it’s going to be available in the HTTP node. Keep in mind that referencing binary data it’s different than referencing JSON data. When referencing binary data, what is important is the binary property name, which it’s called “data” by default. Using the binary data in the HTTP node should look something like below, assuming that you want to send the file/image using multipart/form-data.

Thank you. I’ll try this solution

This works, thank you.

So to bring binary data further, I need to transfere it with a Merge node. But it will bring unwanted paramters too.

Supose I want to put the receipt image in the Airtable in the very end. So I must bring the binary data and JSON data together via the Merge node. But there will be some unwanted fields for Airtable. To get rid of them I could use a Set node and leave only proper fields. But this clear the binary.

use an IF node after merge to keep only what you need?

Also, in the Airtable node you can set the fields you want to be inserted. All other fields will be omitted.

Sorry, only now saw your comment.

First, you have to use SET to populate any field the associated empty JSON flow [{}]. Then you can use IF node to clear out that single record. But that alse moves away the Binary. It’s connected to that JSON-record.

So finally I found how to transfer Binary data even when it is lost after the Set node (with the "Keep… " opton on).

Use Merge by Index, set the Outer Join. It will merge together JSON and Binary, not affecting any of them.

The code:

{
  "name": "JSON + Binary",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        260,
        200
      ]
    },
    {
      "parameters": {
        "url": "https://upload.wikimedia.org/wikipedia/commons/a/a1/Namibie_Etosha_Leopard_01edit.jpg",
        "responseFormat": "file",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        540,
        320
      ]
    },
    {
      "parameters": {
        "mode": "mergeByIndex",
        "join": "outer"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        800,
        180
      ]
    },
    {
      "parameters": {},
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        560,
        40
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          },
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 41
}
1 Like

I had the same problem today, thank you for updating and sharing your solution, it worked well for my purpose!

Actually this was what Ricardo suggested earlier, I don’t remember why i still had that issue. Maybe I occasionaly tried another merging option and had the problem.