Im just trying to create new items, just copied the syntax on your sample app, but i cant seem to create new Items, I dont see exactly whats the error, thanks for the help in advance!
Take note that I am using a trial xero account, not sure if thats the case tho.
im using xero-node to use the xero api.
const Config = use('Config')
const xeroNode = require('xero-node')
const xero = new xeroNode.XeroClient({
clientId: Config.get('xero.client_id'),
clientSecret: Config.get('xero.client_secret'),
redirectUris: [Config.get('xero.redirectUri')],
scopes: Config.get('xero.scopes').split(" ")
})
try {
const item1 = {
code: "Foo" + '123',
name: "Bar",
purchaseDetails: {
unitPrice: 375.5000,
taxType: "NONE",
accountCode: "500"
},
salesDetails: {
unitPrice: 520.9900,
taxType: "NONE",
accountCode: "400",
}
}
const newItems = new xeroNode.Items()
newItems.items = [item1]
const itemCreateResponse = await xero.accountingApi.createItems(xero.tenants[0].tenantId, newItems)
} catch (error) {
console.log(error.response.toJSON())
}
Here is the body of the response (error.response.toJSON().body):
Here is validation error (error.response.toJSON().body.ValidationErrors):
[ { Message: 'The PurchasesAccountId account is invalid.' } ]