xero-node
xero-node copied to clipboard
getInvoiceAsPdf endpoint does not set PDF headers as default
- Version 4.7.6
Describe the bug Similar problem to one reported in Issue #422 whereby the invoice is returned as a Buffer in JSON format rather than a PDF.
Expected behavior
We expected an endpoint entitled getInvoiceAsPdf
to return a PDF as default.
The workaround is xero.accountingApi.getInvoiceAsPdf(activeTenantId, invoiceId, {headers: {Accept: 'application/pdf'}})
Hey @samueldjones24 - agreed this would be ideal to auto-detect.
We've got full examples in the sample app but you make a good point. Added examples for both getting files as PDF, and POSTIng attachments to the core SDK readme!
I think getInvoiceAsPdf
method should do this automatically behind the scenes for you without passing any additional option parameters. The name of the method suggests you'll receive a PDF back.
Agree with the latter :) great to have the option to add headers as well, but it is also missing from the documentation, that'd help to imagine the workaround
Agree with the latter :) great to have the option to add headers as well, but it is also missing from the documentation, that'd help to imagine the workaround
Yes - improvement will be in an upcoming release but a documentation addition in this readme would be a good place to start as we have it shown in the sample app https://github.com/XeroAPI/xero-node-oauth2-app/blob/master/src/app.ts#L1191
This is still the case in 2024. I would put some sort of flag in the documentation while this is ongoing because calling the function as it is now actually returns a json object with the invoice data (so it doesn't throw an error).