Data from earlier node coming as an object that is not convertible to binary

Say I have NodeX that outputs JSON data, and that I have a Move Binary Data to convert the JSON data into Binary data.

Directly Connected Nodes
If I have my Move Binary Data directly connected to NodeX, I can set JSON to Binary and put data in Destination Key. The JSON is converted to binary correctly.

Here is a screenshot showing what that looks like:

You can see it converts properly.

Nodes Not Directly Connected Due To Nodes In Between
However, if I have a few nodes in between NodeX and Move Binary Data, this does not work. The data in Destination Key is pulled from the immediately prior node to Move Binary Data. I tried to work around this by creating an expression to get the data from NodeX.

With a few nodes between the two, I try to use an expression to get the data from NodeX into Move Binary Data. If I try either {{$node["NodeX"].json}} or {{$node["NodeX"].data}} in the Destination Key, I can see the data — but it’s an Object. Move Binary Data can’t convert the Object to Binary

Here is a screenshot of how it looks in the Move Binary Data node’s expression editor (in the screenshot, NodeX is equivalent to the node IF: Symbol):

My question is:
How can I get the data of NodeX as an array, not an Object?

Here is another attempt that did not work:

  1. Using {{JSON.stringify($node["NodeX"].data)}}. The data converts to binary…but the binaries are empty. And the entire array shows as the “binary title” (see screenshots), but I want the array to to be the binary contents.

Any suggestions? And please let me know if I can provide more info :slight_smile:

I found something that seems to work, but I don’t trust it — it seems far too hacky.

Essentially, I added a Function node (AKA FuncY) directly prior to the Move Binary Data node and added the code:

return $items("NodeX");

and this allows me to use data in the Move Binary Data node with no issues.

Is this the correct way to handle this situation?

Here’s a screenshot showing my nodes (IF: Symbol = NodeX and Get back IF: Symbol data = FuncY):

Hey @malasane!

Your solution looks good to me and I would have done exactly what you did.

Thanks, @harshil1712! Good to know — I still think it’s a little confusing (I think n8n should support this built in to the Move Binary Data node), but I’ll go with it for now.