0

Using Xero-node with a custom connection, the createContacts endpoint has been authorised for my app but any attempt to create a contact produces the same error:

  "ErrorNumber": 17,   
  "Type": "NoDataProcessedException",  
  "Message": "No data has been processed for this endpoint. This endpoint is expecting Contact data to be specified in the request body." 

Here's the code used to call xero-node after capturing tokens etc.:

  let response
        const contacts = [{EmailAddress:"any@email.com",Name:"the name"}]
        try {
            response = await xero.accountingApi.createContacts('',contacts,true);
            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}`);
            return {error:"Unable to create Xero contact"}
        }

Anyone know how to make this work?

  • I don't know Xero-node (I use VB for my link) but the doc suggests that the name field is called `name` rather than `Name`, and the email address is called `emailAddress`, not as you have it. I don't know if that matters. You also don't put the tenantID in your `createContacts()` call - is that just for this posting? Have you looked at the sample code: https://xeroapi.github.io/xero-node/accounting/index.html#api-Accounting-createContacts – droopsnoot Sep 02 '22 at 17:04
  • Thanks, droopsnoot. The problem is the same with different casing for the variable names. re. tenantID, I'm using custom connections which according to the docs require an empty string: From: [link](https://github.com/XeroAPI/xero-node#custom-connections) "Because Custom Connections are only valid for a single organisation you don't need to pass the xero-tenant-id as the first parameter to every method, or more specifically for this SDK xeroTenantId can be an empty string." – DoTrustDev Sep 03 '22 at 07:31

1 Answers1

0

This works for me for xero-node: ^4.34.0

let contact = new Contact()
contact.name = NAME
contact.emailAddress = "xxxx"
const apiResponse = await xero.accountingApi.createContacts(
        activeTenantId, { contacts: [contact]}
)

return apiResponse.body.contacts[0]