Still struggling with this guys, any ideas?
I’ve managed to get a bit further with this and it’s returning a PDF file. But the PDF file is blank. Here’s my code in Zapier Platorm..
const customHttpOptions = {
url: 'https://api.xero.com/api.xro/2.0/Quotes/' + bundle.inputData.QuoteID,
headers: {
'Accept': 'application/pdf',
'Authorization': `Bearer ${bundle.authData.access_token}`,
'Xero-tenant-id': bundle.inputData.TenantID
},
};
const fileRequest = await z.request(customHttpOptions);
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 whats not quite right?
I have tried setting the Accept header to “application/json” but it just saves the file as a JSON file..
Hi @BradE - If you’re still having issues with this action, try the following:
const customHttpOptions = {
url: "https://api.xero.com/api.xro/2.0/Quotes/" + bundle.inputData.QuoteID,
headers: {
Accept: "application/pdf",
Authorization: `Bearer ${bundle.authData.access_token}`,
"Xero-tenant-id": bundle.inputData.TenantID,
},
raw: true,
};
const fileRequest = await z.request(customHttpOptions);
const buffer = await fileRequest.buffer();
const url = await z.stashFile(buffer);
return { url };