Chat trigger with attachment unable to pass binary through node

Hi community,
I have the following workflow:
chatinput (with binary) —> a http node (see screenshots and JSON below) , this works and the http node is able to read the binary.
See screenshot:

I then added a function node between the chatinput and the http node, and for some reason the http now seem to have trouble reading the binary file despite that the binary is showing in the input, see screenshot,

It’s complaning with error “This operation expects the node’s input data to contain a binary file ‘data0’, but none was found [item 0]”

I can’t figure out why it failed since the binary definitely passed into the http node.

This is the JSON which is Successful
{
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “https://api.canva.com/rest/v1/asset-uploads”,
“authentication”: “genericCredentialType”,
“genericAuthType”: “oAuth2Api”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Content-Type”,
“value”: “application/octet-stream”
},
{
“name”: “Asset-Upload-Metadata”,
“value”: “={"name_base64": " {{ $json.data[0].name_base64 }} "}”
}
]
},
“sendBody”: true,
“contentType”: “binaryData”,
“inputDataFieldName”: “=data0”,
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-1260,
-420
],
“id”: “ef098c4c-4e40-476a-bdb4-25041afffefa”,
“name”: “Create asset upload job1”,
“retryOnFail”: false,
“credentials”: {
“oAuth2Api”: {
“id”: “YVCjQRRULdiCtLFd”,
“name”: “Canva 1”
}
},
“onError”: “continueErrorOutput”
},
{
“parameters”: {
“options”: {
“allowFileUploads”: true
}
},
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“typeVersion”: 1.1,
“position”: [
-1600,
-420
],
“id”: “9a7b794b-ae60-43a3-99a5-d019237b4ede”,
“name”: “When chat message received”,
“webhookId”: “04d62079-9f1b-40b7-b5bc-85d7de4f59cc”
}
],
“connections”: {
“Create asset upload job1”: {
“main”: [

]
},
“When chat message received”: {
“main”: [
[
{
“node”: “Create asset upload job1”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“instanceId”: “558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a”
}
}

This is the JSON which Failed
{
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “https://api.canva.com/rest/v1/asset-uploads”,
“authentication”: “genericCredentialType”,
“genericAuthType”: “oAuth2Api”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Content-Type”,
“value”: “application/octet-stream”
},
{
“name”: “Asset-Upload-Metadata”,
“value”: “={"name_base64": "VGhlIGNyZWF0aW9uIG9mIHRoZSB3b3JsZA=="}”
}
]
},
“sendBody”: true,
“contentType”: “binaryData”,
“inputDataFieldName”: “=data0”,
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-1060,
-440
],
“id”: “ef098c4c-4e40-476a-bdb4-25041afffefa”,
“name”: “Create asset upload job1”,
“retryOnFail”: false,
“credentials”: {
“oAuth2Api”: {
“id”: “YVCjQRRULdiCtLFd”,
“name”: “Canva 1”
}
},
“onError”: “continueErrorOutput”
},
{
“parameters”: {
“mode”: “runOnceForEachItem”,
“jsCode”: “// Input JSON might look like: { "fileName": "My Awesome Upload :tada:" }\n\n//const name = $input.item.json[‘[\‘Title/Theme of Bible Story\’]’] || ‘Untitled’;\nconst name = $json.chatInput;\n\nreturn {\n json: {\n name_base64: Buffer.from(name).toString(‘base64’),\n decoded_name: name,\n }\n};”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
-1300,
-440
],
“id”: “3121d4c9-2781-48fd-8d2c-5b3980d42d03”,
“name”: “Convert text to base”
},
{
“parameters”: {
“options”: {
“allowFileUploads”: true
}
},
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“typeVersion”: 1.1,
“position”: [
-1540,
-440
],
“id”: “9a7b794b-ae60-43a3-99a5-d019237b4ede”,
“name”: “When chat message received”,
“webhookId”: “04d62079-9f1b-40b7-b5bc-85d7de4f59cc”
}
],
“connections”: {
“Create asset upload job1”: {
“main”: [

]
},
“Convert text to base”: {
“main”: [
[
{
“node”: “Create asset upload job1”,
“type”: “main”,
“index”: 0
}
]
]
},
“When chat message received”: {
“main”: [
[
{
“node”: “Convert text to base”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“instanceId”: “558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a”
}
}

Information on your n8n setup

  • n8n version: 1.98.2
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

Thanks for taking time assisting.

Hey @jerry_Cole

Just try one thing I am sharing a node (MAGIC NODE) below, just copy this node and add this in between the code node and http node…and let me know if it works for you or not.

Check this screenshot to see where to place this node

1 Like

Hello @Sudhanshu_Sharma thanks for that. It worked!

Although I don’t understand why, but thanks heaps!

1 Like

Hey @jerry_Cole,

Let me explain how it works.

Basically, while working on n8n workflows, it’s kind of difficult to reference binary files from any previous node, just like how we can easily reference the JSON from the previously executed node.

So, what this code does is simply combine two things: the output from the “Convert text to base” node and the binary file from the previous node. so that we can access the both of these things together while make http call.

That’s how it works.

Thanks @Sudhanshu_Sharma . That make sense. :slightly_smiling_face:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.