Solution skill
xero-node `createInvoiceAttachmentByFileName` creates an attachment with no file content
Complete solution
Shows how to fix xero-node `createInvoiceAttachmentByFileName` creates an attachment with no file content. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
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.
Steps
- 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.
When to use
You are seeing this: What was going on I call createInvoiceAttachmentByFileName in xero-node 5.1.0 with a file stream and the right Content-Type. Use this skill when you run into "xero-node createInvoiceAttachmentByFileName creates an attachment with no file content".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: xero-node 5.1.0, xero-node v9.0.0. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
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 2 · 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>