-
Notifications
You must be signed in to change notification settings - Fork 91
Description
I am trying to make this request through Xero API Explorer
https://api-explorer.xero.com/accounting/invoices/createinvoices?query-unitdp=4
{
"Invoices": [
{
"Type": "ACCREC",
"Contact": {
"ContactID": "15976e62-37ad-4065-8bba-d8c5c264e078"
},
"LineItems": [
{
"Description": "tiered-plan",
"Quantity": 8555500,
"UnitAmount": 0.000149611361,
"AccountCode": "4000",
"TaxType": "TAX001",
"taxAmount": 256,
"ItemCode": "cp_oct17_tiered",
"LineAmount": 1280
},
{
"Description": "stair-step",
"Quantity": 8555500,
"UnitAmount": 0.000029104,
"AccountCode": "4000",
"TaxType": "TAX001",
"taxAmount": 49.8,
"ItemCode": "cp_oct17_stairstep",
"LineAmount": 249
}
],
"Date": "2023-03-11",
"DueDate": "2022-12-10",
"Reference": "Website Design",
"Status": "AUTHORISED"
}
]
}
Getting below validation error:
"ValidationErrors": [
{
"Message": "Account must be valid."
},
{
"Message": "Tax rate must be valid."
}
]
This is totally unexpected, as I am using same account and same tax code for other requests as well and all of them getting success.
Later I tried altering content of above request, I updated UnitAmount for second lineItem from
"UnitAmount": 0.000029104 to "UnitAmount": 0.0000291
And to my surprise, old validation error gone and now I am getting mismatch error.
New Request
{
"Invoices": [
{
"Type": "ACCREC",
"Contact": {
"ContactID": "15976e62-37ad-4065-8bba-d8c5c264e078"
},
"LineItems": [
{
"Description": "tiered-plan",
"Quantity": 8555500,
"UnitAmount": 0.000149611361,
"AccountCode": "4000",
"TaxType": "TAX001",
"taxAmount": 256,
"ItemCode": "cp_oct17_tiered",
"LineAmount": 1280
},
{
"Description": "stair-step",
"Quantity": 8555500,
"UnitAmount": 0.0000291,
"AccountCode": "4000",
"TaxType": "TAX001",
"taxAmount": 49.8,
"ItemCode": "cp_oct17_stairstep",
"LineAmount": 249
}
],
"Date": "2023-03-11",
"DueDate": "2022-12-10",
"Reference": "Website Design",
"Status": "AUTHORISED"
}
]
}
Response Error
"ValidationErrors": [
{
"Message": "The line total 249.00 does not match the expected line total 248.97"
}
]
I would like to know what does Account must be valid / Tax rate must be valid error mean and what was the reason for this error as I am using same account and tax rate for all other requests. Was there some other internal error which is not passed in final response ?