How to access an attachment posted to a webhook

Hey

I’m POSTing data from Mailgun to a Webhook; the POST includes an XLSX attachment.

How can I access the attachment to use it in an HTTP POST further down the workflow?

Thanks!

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

In your webhook specify the field to store the file:
image

Then in the following node you can access it from {{ $binary.data }}

Thanks, @JayF

I did try that, but I seem to be getting the details of the attachment, not the binary file:

And it gives this error:

in Input Data Field Name, just write the string ‘data’ . No expression needed :slight_smile:

Still not having any luck, here are a couple of screenshots:

This is because your webhook is giving the data in field data0.
To make sure you get the file regardless of the name, you can set Input Data Field Name to expression: Object.keys($binary)[0], which will automatically use the right field as given by the previous node.

I think I can see what’s happening.

My workflow is:

  1. Webhook trigger from Mailgun
  2. Get an authorization token from my API
  3. Post the file to my API using the authorization token

I can get to the file immediately after the Webhook, but it’s unavailable later in the flow. I tried a merge node to see if that would fix the problem, but it didn’t

What is the best practice to use a binary file later in a flow?

$('nodename').item.binary['data0']

Hi Jay

I really appreciate all your help here, but this still isn’t working as expected.

The frustration is we are evaluating to take an enterprise contract with n8n, an this use case has been achieved in minutes using make.com.

Here are the screenshots.

I’d be more than happy to pay for a consultant to help with this.


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