Download a PDF file from a webpage and send it as an attachment
What is the problem?
The last module doesn’t receive the file name nor the attachment content
What have you tried so far?
The scenario runs fine to the PDF download (step #8). The output looks correct, the variables contains the expected values.
However, the next step, Sendgrid, complains those attributes are empty. I cannot understand why.
This isn’t really a SendGrid problem. The PDF is downloading correctly, but the attachment mapping is the issue. In the SendGrid module you need to map the binary file data, not just the file name. If only the name is mapped, SendGrid treats the attachment as empty.
Once you map the Data output from the HTTP download step into the attachment field, it should work fine.
What do you mean with mapping the data? In the SendGrid module I used both the File Name and the Data fields. However, even if they’re retrieved correctly (as shown in the debug JSON), the mailing module complains those fields are empty!
Ok I think I found, I added an array aggregator to map the HTTP download, and then used this output in the SendGrid attachment! Thank you for your help!
What I mean is this: in SendGrid, the attachment Data field has to come straight from the Data (binary) output of the HTTP Get a file module. If it’s coming from a variable, JSON, or anything that isn’t raw binary, SendGrid will still say it’s empty, even if the debug looks fine.
Also double-check that you’re using Get a file (not Make a request) and that the attachment toggle is on. Once the binary data is mapped directly, it should work.
Yep, that makes total sense. SendGrid expects the attachments as an array, so using the Array Aggregator to wrap the HTTP download output is exactly the right move. Once it’s in the proper structure, SendGrid finally stops complaining about empty fields
Thanks for sharing the solution. This will definitely help others who run into the same issue.