我只是尝试创建新项目,只是在示例应用程序上复制了语法,但是我似乎无法创建新项目,我看不到确切的错误,感谢您的提前帮助!
请注意,我正在使用试用版xero帐户,不确定是否这样。
我使用xero-node来使用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())
}
以下是响应的正文(error.response.toJSON()。body):
这是验证错误(error.response.toJSON()。body.ValidationErrors):
[ { Message: 'The PurchasesAccountId account is invalid.' } ]
答案 0 :(得分:0)
发生此错误的原因有很多:
希望这会有所帮助。