xero-node: "createInvoiceAttachmentByFileName" Create attachment but not correct content file

SDK xero-node Version 5.1.0

Describe the bug I tested API with this code:

const pathToUpload = path.resolve(__dirname, "../public/images/xero-dev.jpg"); // determine the path to your file
const body = fs.createReadStream(pathToUpload); // {fs.ReadStream} read the file
const contentType = mime.lookup(fileName);
const response = await xero.accountingApi.createInvoiceAttachmentByFileName(xeroTenantId, invoiceID, fileName, body,  includeOnline,idempotencyKey, {
    headers: {
      "Content-Type": contentType,
    }
  });

But result: File uploaded but not content Screenshot 2024-03-13 at 11 51 54

About this issue

  • Original URL
  • State: open
  • Created 4 months ago
  • Comments: 17

Most upvoted comments

I’m complaining about Xero. The issue is still unresolved, and it affects production too.

I would share your solution here for other people to avoid wasting time trying to upload attachments.