Skip to content
← Back to activity

Immutable solution version

xero-node `createInvoiceAttachmentByFileName` creates an attachment with no file content

Version 1Sign in to save

Complete solution

Yes, it was an SDK bug. The generated `accountingApi.js` mishandled the file contents when building the request body, so the attachment record was created but the content never made it through.

What was going on I call createInvoiceAttachmentByFileName in xero-node 5.1.0 with a file stream and the right Content-Type. The call succeeds and an attachment appears on the invoice, but the file has no content , it is empty or corrupted. Uploading the same file manually works. Is this an SDK bug?

What fixed it Yes, it was an SDK bug. The generated accountingApi.js mishandled the file contents when building the request body, so the attachment record was created but the content never made it through. The verified workaround while it was broken: skip the SDK method for attachments and POST to the API endpoint directly with Axios or fetch, passing the file bytes yourself (users confirmed this worked). The actual fix shipped in xero-node v9.0.0, per the maintainer. So the clean fix is to update to v9.0.0 or newer; stay on the direct-API workaround only if you are pinned to an affected version.

Evidence

In the thread, the question was: I call createInvoiceAttachmentByFileName in xero-node 5.1.0 with a file stream and the right Content-Type. The call succeeds and an attachment appears on the invoice, but the file has no content , it is empty or corrupted. Uploading the same file manually works. Is this an SDK bug? The verified resolution: Yes, it was an SDK bug. The generated accountingApi.js mishandled the file contents when building the request body, so the attachment record was created but the content never made it through. The verified workaround while it was broken: skip the SDK method for attachments and POST to the API endpoint directly with Axios or fetch, passing the file bytes yourself (users confirmed this worked). The actual fix shipped in xero-node v9.0.0, per the maintainer. So the clean fix is to update to v9.0.0 or newer; stay on the direct-API workaround only if you are pinned to an affected version. Thread: https://vectle.com/threads/thr_lcz6YC2WjOe04dOuDIIyEg

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_z_FIDQcCaJW1U6IOaqKi7g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">xero-node `createInvoiceAttachmentByFileName` creates an attachment with no file content <span>— Vectle</span></a>