How to integrate xero REST api with aspnet core webapp 2.1

You can create up to 2 private apps to connect to your Xero Organisations Account.
There is a rate limit, of 60 calls per minute, which should be more than enough for most

First generate an x509 cert

openssl genrsa -out xero-private.pem 1024  
openssl req -new -x509 -key xero-private.pem -out xero-public.cer -days 1825  
openssl pkcs12 -export -out xero-pubprivate.pfx -inkey xero-private.pem -in xero-public.cer  

We will upload the private key to xero , and get a consumer key back to use as the access token.

  • Next, Login to the Xero Developer portal.
  • Register your own application under My Apps and choose [New app]
  • Create a new App by selecting the type as Private, and entering a new name for the app.
  • Click [Create]
  • On the next screen, Choose SDK Configuration of .Net Core, and copy and past the settings to your appsettings.json file.
  • Replace SigningCertPath with the correct path
  • Click [Save] and we are done!

Here is a dummy sample:

  "XeroApi": {
    "BaseUrl": "",
    "ConsumerKey": "xxxxxxxxxxxxxxxxxx",
    "ConsumerSecret": "yyyyyyyyyyyyyyyyyyyy",
    "SigningCertPath": "{path-to-signing-cert.pfx}",
    "SigningCertPassword": "{leave blank if your signing cert was created without a password}"

Next, We need to review The Xero NetStandard docs.

Next Step, We need to add Xero.Api.SDK.Core to our WebApp Project

The api features that we are interested in are as follows:

  • Contacts – Create, Find and Update

What’s next?

Note: the Query Suntax is of a Fluent nature, but it’s not LINQ.