Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > SDKs >

New wrapper for .Net

Started by Richard Rowley (Xero Staff) -   in SDKs

HI all,

We've been working on a different wrapper for the API. You can find it on GitHub. It has the same license as our other wrapper. Feel free to give it a go. Try the samples and run the tests.

We've covered the Core API and also the Payroll functionality for Australia and America (Beta)

Give us feedback, raise issues and give pull requests.

We know there are a few things missing (such as partner renewal and nuget) but we will be getting on to it.

Thanks for the effort it's great to know there is still developers giving back to the community.

Henzard Kruger  

Hi Richard,

Thanks for posting this. Here's hoping this one gets the resources to be kept up to date more than the last one did!

Any possibility for a roadmap or something like that? We're interested to see if the new Setup endpoint is going to make an appearance.


Matthew Steeples  

@Matthew one of the intentions was to make a wrapper that can be easily maintained and enhanced in tandem with new API feature development.

Setup endpoint is a fair call although I believe you may be the only user on the .NET stack :)
We should get it in for the sake of completeness now rather than later.

I've just opened a feedback forum for code samples also, so we can more effectively track feature requests and treat code samples as an extension of the API product.

Ronan Quirke (Community Manager)  

@Matthew - Richard was feeling generous today: https://github.com/XeroAPI/Xero-Net/pull/2 - thanks Richard!

Ronan Quirke (Community Manager)  


I have been trying to use the wrapper within my project but there is an issue.

I have specified the callback url in the config file but the wrapper doesn't seem to work after that.

Can you please provide a sample or guidelines about how to use the wrapper with a callback other than "oob" ?

Thanks a lot.

Basit Munir

Basit Munir  


I downloaded and built this yesterday and replaced the old XeroAPI with this one. I have Invoices, Payments and Credit Notes are working as they were before but I was hoping to now be able to allocate Credit Notes to Invoices. I have tried adding the allocation to the CreditNote before calling api.Create(). I have also tried calling api.Create(), adding the Allocation, then calling api.CreditNotes.Update(). In the Xero client website I can see the Invoice and the Credit Note but they are not linked.

I am also yet to work out how to set Tracking Categories.

Any examples would be appreciated.

Thanks in advance,
Damian Kennedy, Houston Medical.

Damian Kennedy  


First question: For partner application, can this wrapper use existing authentication tokens? In release notes on NuGet I saw this new wrapper do not support token renewal for partner applications. How do you suggest to proceed with this wrapper if we do use partner mode and can not force people to reauthenticate with Xero every time they want to sync?

Second question: If our app's certificates are not stored in file system but uploaded to Azure, how do I specify path to these certificates in config file?

It would be great to see a functionality comparison table to understand what is possible and what is not if you compare it with previous .NET wrapper.

Having to completely rewrite integration is a bit too much when the only thing that we miss in old wrapper is 4 decimal support for prices. Maybe there is a way to enable this functionality in the old wrapper?

Thank you,
Allan Pinkerton

DEAR Team  

Can just add to Damian's post above on the importance of credit note allocations, as a user my last financial year is literally swollen with millions of dollars of unallocated credit notes! Of course I could manually allocate these thousands of credit notes, but given allocations were available in the API, I thought the .net wrapper would accommodate this at some stage?

Also, and just as important, is there any intention to accommodate the direct creation, and invoice allocation, of PREPAYMENTS in the .net wrapper? If I read the release notes correctly, this feature is available in the API?

Again this would be a hair-saver from a user perspective. From a cloud integrator perspective, I can categorically state that these issues are preventing new Xero sales.

Very much appreciate your work on the new wrapper and welcome any indication for the above. Many thanks

Marcus Wilson  


I have spent some time developing against the previous API is that not recommended now at all?
Is the new API using the same object tree/ hierarchy and do I have to change over any time soon or is it a Beta?


Steve Jones  

@Steve please understand that there is a difference between the code samples and wrapper libraries we provide, and the underlying API. The underlying API has not changed.

You can continue to use the old .NET wrapper library if it does what you need it to, but you should not expect any enhancements to it to come from Xero.

@Allan the new wrapper library is just code, so yes if you plug in the same application values (certs, consumer keys etc), then the existing access tokens will work. As you note, we have not yet done the work to add partner token renewal yet, we are putting the code out there to evaluate developer response and will enhance as we go.

To your point, it is really a decision for yourself - since the source code of the previous wrapper library is available on GitHub, you have the option of adding 4DP support in yourself or implementing the new wrapper library. Either will involve work for you I'm afraid.

It is hard for me to say which course is best for you, but if you are relatively happy with the range of functionality your integration has with the Xero API other than 4DP support, then you might lean towards simply modifying the existing old wrapper source.

If you thing features such as Payroll API support is something you might need in the future, then switching over might be the better course of action.

@Marcus & @Damian - will do some digging on credit note allocations....

Ronan Quirke (Community Manager)  

Thank you RQ, the response is much appreciated.

Marcus Wilson  

I'm having trouble querying with the new api wrapper I was using this:-
var Ledgers = repository.Accounts.Where(a => a.Type == "DIRECTCOSTS" || a.Type == "REVENUE").ToList();

which worked fine I'm trying to do the same with the new api I've got this:-
var Ledgers = api.Accounts
.Where("Type, DIRECTCOSTS")

I'm getting this error:-

No property or field 'DIRECTCOSTS' exists in type 'Account'

Any help would be much appreciated.



John Sutton  

Sorry correction to last post I did have


John Sutton  

Hi Me again

How to I check the status of invoice that have been created.

e.g. I was using invoice.ValidationErrors how do I do this with the new api?



John Sutton  

Sorry to keep posting but I've got most of this working now but have left out some functionality that I had before.

I was getting the CurrencyRate from invoices as I create then in the response and updating our system. I was also able to populate the Reference field on invoices when I create them.

I'm guessing I need to extend the new api somehow to do the same.

Can someone please point me in the right direction how to do this I've not much experience with http stuff so these wrappers are really useful for me.

Thanks in advance



John Sutton  

Think you for response Ronan. i understand that you are trying to change the concept with new wrapper and once it is out of beta and provides the same range of functionality as the old one we will definitely switch over.

My question is: would you consider adding a simple configuration option or additional constructor for old wrapper repository to enable 4dp support? We can do this ourselves but i'm sure that this change will benefit many others while you are working on the new wrapper.

Best Regards,

DEAR Team  

@Allan we are not planning any further work on the old wrapper library, but we are accepting source contributions from others which we will merge in for all to use.

@Marcus & @Damian - the good news is that Richard has added support for allocations in the last day or so.

@John - it seems like you are struggling to get started a bit. Rather than adding to this thread, it would be preferable to create a separate topic so we can help you out.

Ronan Quirke (Community Manager)  

Thanks Ronan, that is fantastic news.
Can you shed any light on wrapper support for creating prepayments ?
And any update on the API being able to make a cash refund from a prepayment, or allocate prepayments to invoices? Once available in the API, I assume the wrapper support will quickly follow?
Then after tracking codes are supported (i understand this is very close), I will shut up. Promise.
Many thanks again!

Marcus Wilson  

OK Thanks will do that now

John Sutton  

Cheers Richard and Ronan, allocations are working fine now.

Damian Kennedy  

Any idea when this'll go up on NuGet?

You've updated the docs telling us not to use the old c# implementation but that's all that's available at the moment.

Martin Steel  

Hi I started a new here discussion as requested


Any chance of some help. The main thing I need is when creating a batch of invoices I want to get the currency rate and whether each invoice created or not.



John Sutton  

@Ronan I just submitted a pull request on github which includes 4DP flag by default. Please review and merge. Thanks.

Shawn Jiang  

Have just started Xero development and noticed the old and new C# libs. Only the old one is available via Nuget. Will the new one be available soon? (ie official packages to use etc?).

I'm fine grabbing source off Github and working off that, but having specific release versions etc would be nice.



Ken Faulkner  


We are working with Xero - Podio integration and we need some way to refresh the expired tokens. Are you planning to implement it soon.

We can see you have mentioned it as a coming soon feature. Can you please let us know if there is a timeline planned for this so that we can plan our integration accordingly.


Anz M  

Anyone tried to transform the existing Xero.Api.Example.Counts to private?
I tried to replace "new Applications.Public.Core(tokenStore, user)" with "new Applications.Private.Core()" so my code looks this:

var user = new ApiUser { Name = Environment.MachineName };
var tokenStore = new SqliteTokenStore();
var api = new Applications.Private.Core()
UserAgent = "Xero Api - Listing example"

new Lister(api).List();

I have the right values in app.config for "ConsumerKey", "ConsumerSecret", "CallbackUrl" and "SigningCertificate"

but in the Lister, when I try to read _api.Organisation.LegalName at

public void List()
Console.WriteLine("Your organisation is called {0}", _api.Organisation.LegalName);

I got this error at:

if (response.StatusCode == HttpStatusCode.Unauthorized)
throw new UnauthorizedException(response.Body);

'Xero.Api.Infrastructure.Exceptions.UnauthorizedException' occurred in Xero.Api.dll

Additional information: oauth_problem=token_rejected&oauth_problem_advice=Token has not been provided

I think will be very usefull to have a private example on github...

Someone have any idea, what I need to do?

Robert Olah  

I have found, the error message is caused by a modification in API OAuth Signing..

Robert Olah  

Hi Guys ,

I am having a small issue with the current implementation for payroll ;
the basic issue is when I try to create an employee using the .Net library for Xero I am getting a XML error.

The .Net libraries are obtain from https://github.com/XeroAPI/XeroAPI.Net
Error Message is : {"There is an error in XML document (1, 1)."}

Code for creating an employee :

Dim employee As New Payroll.Employee With
{ _
.FirstName = "Jame",
.LastName = "Oliver",
.Email = "james@test.com",
.Phone = "04555555555",
.Mobile = "04555555555",
.DateOfBirth = New DateTime(1989, 2, 2),
.StartDate = New DateTime(2015, 6, 2),
.HomeAddress = New HomeAddress() With { _
.AddressLine1 = "North 2",
.AddressLine2 = "Street",
.City = "Melbourne",
.Country = "Australia",
.PostalCode = "3000",
.Region = Enums.State.VIC


then I get an error ; as you can see I am not using XML to create the Employee.

Any help would be appreciated.


Uthayakumar Chakarapani  

Hi Richard
i am trying to Integrate xero with Dynamics crm using xer net wrapper
i am developing a plugin in that i want to use xero api how can i use this.

i tried by adding dll's but when i am bulding this it says dependencies are missing.

Thanks In Advance.


santhosh santhu