0

We are trying to create a bank transaction through the Xero API:

Here is the curl statement:

curl --location --request POST 'https://api.xero.com/api.xro/2.0/BankTransactions' \
--header 'Authorization: Bearer ' \
--header 'Xero-Tenant-Id: ' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Cookie: ' \
--data-raw '{
   "bankTransactions":[
      {
         "type":"RECEIVE",
         "contact":{
            "contactID":"1db8660c-387a-45e9-943e-269a0fa9f6b39"
         },
         "lineItems":[
            {
               "description":"Foobar",
               "TaxType":"NONE",
               "quantity":1.0,
               "unitAmount":20.0,
               "accountCode":"4567"
            }
         ],
         "bankAccount":{
            "code":"4567"
         }
      }
   ]
}'

We get an account by calling Get Account API and we get a response:

{
            "AccountID": "5aef5a57-f9f7-401f9-a627-30708840fb2",
            "Code": "4567",
            "Name": "Xero Integration",
            "Status": "ACTIVE",
            "Type": "BANK",
            "TaxType": "NONE",
            "Class": "ASSET",
            "EnablePaymentsToAccount": false,
            "ShowInExpenseClaims": false,
            "BankAccountNumber": "456789",
            "BankAccountType": "BANK",
            "CurrencyCode": "USD",
            "ReportingCode": "ASS.CUR.CAS.CAS",
            "ReportingCodeName": "Cash on hand",
            "HasAttachments": false,
            "UpdatedDateUTC": "/Date(1670594412700+0000)/",
            "AddToWatchlist": false
},

We get the validation error:

"Account code '4567' is not a valid code for this document."

I have checked the account code multiple times and everything looks good to me. Let us know what are we doing wrong.

API call by changing the account code and bank account code

Nir
  • 1

1 Answers1

1

The line item in the bank transaction needs to be a different account, you can't post a line item to a bank account.

Usually, for a receive money transaction, it would be a revenue account eg 200 Sales.

sallyhornet
  • 364
  • 2