0

I am using the Xero-node SDK to automatically create client invoices which works well.

At the end of the process, I would like to automatically email the client the invoice.

In the documentation it has the following example:

const xeroTenantId = 'YOUR_XERO_TENANT_ID';
const invoiceID = '00000000-0000-0000-0000-000000000000';

const requestEmpty: RequestEmpty = { };

try {
  const response = await xero.accountingApi.emailInvoice(xeroTenantId, invoiceID, requestEmpty);
  console.log(response.body || response.response.statusCode)
} catch (err) {
  const error = JSON.stringify(err.response.body, null, 2)
  console.log(`Status Code: ${err.response.statusCode} => ${error}`);
}

I have 2 questions:

  1. The requestEmpty method does not work in javascript. Does anyone know the correct structure of requestEmpty?

I have used requestEmpty = { } but this throws an error => even though the system does actually send an email (probably a bug)

AND....

  1. Is there a way for me to specify the email template that I would like the invoice to use (if I have specific templates setup in the web version)? Currently it seems to use the default Xero email template.
Fraser
  • 1

1 Answers1

0

If you don't get an answer to your first query here, please can you raise it on the SDK page in Github and the Xero SDK team will look into this for you.

With regards to point 2, it is not possible to choose the email template when sending through the API, a basic template is used.

sallyhornet
  • 364
  • 2
  • => Thank you very much for answering. The email is sent if I put { } (note space between the brackets) in the requestEmpty element of the API, yet returns an error => not too much to worry about as it still sends the email which is what I need to happen. With regards to point 2, it would be great if you could specify which email template you'd like to send as they are specific to different products etc. Is there somewhere to put development requests for the Xero API? Thanks again :) – Fraser Feb 10 '23 at 10:29