0

I've created a custom action in the Zapier Developer Platform. My task is to load a PDF file from the Xero accounting software into Zapier so that I can use it in my zap to attach to an email.

So far I have the code below which returns a successful response, but unfortunately the PDF file is always blank:

const pdfURL = {
  url: 'https://api.xero.com/api.xro/2.0/Quotes/' + bundle.inputData.QuoteID,
  method: 'GET',
  headers: {
    'Accept': 'application/pdf',
    'Authorization': `Bearer ${bundle.authData.access_token}`,
    'Xero-tenant-id': bundle.inputData.TenantID
  }
};
const fileRequest = await z.request(pdfURL);
const url = await z.stashFile(fileRequest); // knownLength and filename will be sniffed from the request. contentType will be binary/octet-stream
return {url};

Any ideas what could be wrong?

Thanks in advance.

V4n1ll4
  • 5,973
  • 14
  • 53
  • 92

1 Answers1

0

I encountered a similar issue with storing PDFs and I noticed if I used raw: true in the call, it actually started storing the data in the pdf file zapier holds for you.

Give that a shot and let me know if it works!

const pdfURL = {
  url: 'https://api.xero.com/api.xro/2.0/Quotes/' + bundle.inputData.QuoteID,
  method: 'GET',
  headers: {
    'Accept': 'application/pdf',
    'Authorization': `Bearer ${bundle.authData.access_token}`,
    'Xero-tenant-id': bundle.inputData.TenantID
  },
  raw: true
};
const fileRequest = await z.request(pdfURL);
const url = await z.stashFile(fileRequest); // knownLength and filename will be sniffed from the request. contentType will be binary/octet-stream
return {url};
Anton
  • 19
  • 1