Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Add-ons >

how to create bank account using API

Started by Walt Levengood -   in Add-ons

I tried to create bank account using .net API. I got no error or exception. But the account Id I got back is always 00000000-0000-0000-0000-000000000000. And the bank account is not actually created.

this is the code:

XeroApi.Model.Account account = new XeroApi.Model.Account();
account.Code = "code";
account.Name = "name";
account.Type = "BANK";
account = repository.Create(account);

please advise.

thanks.
The required minimum elements to create BANK accounts are different than creating regular accounts (Sales, Expenses etc). Based on the code above, you haven't put <BankAccountNumber> element.

There are examples here - http://developer.xero.com/documentation/api/accounts/#title3
 

W. Abdullah (Community Manager)  

Thanks for your reply.

I tried to add account number into it. but I still got back account Id as 00000000-0000-0000-0000-000000000000.

The code is:

XeroApi.Model.Account account = new XeroApi.Model.Account();
account.Code = "code";
account.Name = "name";
account.Type = "BANK";
account.BankAccountNumber = "123-456-1234567";
account = repository.Create(account);
 

Walt Levengood  

Is your application designed to capture the validation error message that Xero API returned?

Here is what Xero API returned:
<ValidationError>
<Message>MerchantCashCapital is too long. Maximum of 10 characters allowed</Message>
</ValidationError>

Thus you need to use shorter characters for the Code field
 

W. Abdullah (Community Manager)  

I tried to put a short name and code in, it still doesn't work.

the code is:
XeroApi.Model.Account account = new XeroApi.Model.Account();
account.Code = "0999";
account.Name = "Loan Test";
account.Type = "BANK";
account.BankAccountNumber = "12345678";
account.CurrencyCode = "USD";
account = repository.Create(account);

I am using the C# API DLL provided in the sample code. How could I enable tracing or logging using it?

Please advise.

Thanks a lot.
 

Walt Levengood  

I tried to enable tracing in my App.config file. But the logging file was never generated.
 

Walt Levengood  

I solved this problem.

thanks.
 

Walt Levengood