Skip to content

Instantly share code, notes, and snippets.

@mervintankw
Created December 19, 2018 08:08
Show Gist options
  • Save mervintankw/a784d4ece60e81cb741f87ec2d1bff4f to your computer and use it in GitHub Desktop.
Save mervintankw/a784d4ece60e81cb741f87ec2d1bff4f to your computer and use it in GitHub Desktop.
Xero API Bank Transaction API Request with incorrect validation on field Type
// Got the request and response messages via Xero API History on API calls.
// Request message
{"BankTransactions":[{"Type":"RECEIVE","Contact":{"ContactID":"fc6cb299-ea76-4bc9-881d-bbd71db9a60f","ContactStatus":"ACTIVE","Name":"First Thai Food","EmailAddress":"","BankAccountDetails":"","Addresses":[{"City":"","Region":"","PostalCode":"","Country":"","AddressType":"STREET"},{"City":"","Region":"","PostalCode":"","Country":"","AddressType":"POBOX"}],"Phones":[{"PhoneNumber":"","PhoneAreaCode":"","PhoneCountryCode":"","PhoneType":"DEFAULT"},{"PhoneNumber":"","PhoneAreaCode":"","PhoneCountryCode":"","PhoneType":"DDI"},{"PhoneNumber":"","PhoneAreaCode":"","PhoneCountryCode":"","PhoneType":"FAX"},{"PhoneNumber":"","PhoneAreaCode":"","PhoneCountryCode":"","PhoneType":"MOBILE"}],"DefaultCurrency":"SGD"},"LineItems":[{"Description":"Employee lunch","Quantity":1,"UnitAmount":32,"AccountCode":"461","TaxType":"INPUT","TaxAmount":2.09,"LineAmount":32}],"BankAccount":{"AccountID":"617b2867-3e64-45ed-a40b-e6dd72106def"},"IsReconciled":true,"Date":"2018-01-29T00:00:00.000Z","Reference":"","CurrencyCode":"SGD","CurrencyRate":"1","Status":"AUTHORISED","LineAmountTypes":"Inclusive","SubTotal":29.91,"TotalTax":2.09,"Total":32,"BankTransactionID":"a8910f79-c870-4dae-85bc-a4d0f9ed12fa","HasAttachments":false}]}
// Response message
{
"ErrorNumber": 10,
"Type": "ValidationException",
"Message": "A validation exception occurred",
"Elements": [
{
"BankTransactionID": "a8910f79-c870-4dae-85bc-a4d0f9ed12fa",
"BankAccount": {
"AccountID": "617b2867-3e64-45ed-a40b-e6dd72106def",
"ValidationErrors": []
},
"Type": "CASHREC",
"Reference": "",
"IsReconciled": true,
"CurrencyRate": 1.000000,
"HasAttachments": false,
"Contact": {
"ContactID": "fc6cb299-ea76-4bc9-881d-bbd71db9a60f",
"ContactStatus": "ACTIVE",
"Name": "First Thai Food",
"EmailAddress": "",
"BankAccountDetails": "",
"Addresses": [
{
"AddressType": "STREET",
"City": "",
"Region": "",
"PostalCode": "",
"Country": "",
"ValidationErrors": []
},
{
"AddressType": "POBOX",
"City": "",
"Region": "",
"PostalCode": "",
"Country": "",
"ValidationErrors": []
}
],
"Phones": [
{
"PhoneType": "DEFAULT",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": "",
"ValidationErrors": []
},
{
"PhoneType": "DDI",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": "",
"ValidationErrors": []
},
{
"PhoneType": "FAX",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": "",
"ValidationErrors": []
},
{
"PhoneType": "MOBILE",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": "",
"ValidationErrors": []
}
],
"ContactGroups": [],
"DefaultCurrency": "SGD",
"ContactPersons": [],
"HasValidationErrors": false,
"ValidationErrors": []
},
"DateString": "2018-01-29T00:00:00",
"Date": "\/Date(1517184000000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Inclusive",
"LineItems": [
{
"Description": "Employee lunch",
"UnitAmount": 32.0,
"TaxType": "INPUT",
"TaxAmount": 2.09,
"LineAmount": 32.00,
"AccountCode": "461",
"Tracking": [],
"Quantity": 1.0000,
"ValidationErrors": []
}
],
"SubTotal": 29.91,
"TotalTax": 2.09,
"Total": 32.00,
"CurrencyCode": "SGD",
"ValidationErrors": [
{
"Message": "The Type field is not valid. This must be either 'SPEND', 'RECEIVE', 'SPEND-PREPAYMENT', 'RECEIVE-PREPAYMENT', 'SPEND-OVERPAYMENT', or 'RECEIVE-OVERPAYMENT'."
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment