Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Find a Developer >

Consultancy on getting started with c# MVC app

Started by ross woodward -   in Find a Developer

Hi Folks,

I'm looking for a developer to help point me in the right direction. I'm currently writing a management app in c# mvc, and I want to integrate with Xero - I've done integrations with command line programs but I just seem to be banging my head against a wall with getting oAuth2 working with c# mvc.

The sample code (using xero.netstandard.oauth2) shows

var client = new XeroClient(xconfig);
however the ide gives an error that XeroClient now expects 2 parameters and I need to pass it an httpClientFactory too.

All I want is to be able to establish an API connection and be able to refresh the token - I can handle the rest from there!

I've currently got the ability to generate a token & store it in my database, and I can get a list of invoices back using

var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", myUser.usrXeroToken);

using (var requestMessage = new HttpRequestMessage(System.Net.Http.HttpMethod.Get, "https://api.xero.com/api.xro/2.0/Invoices"))
requestMessage.Headers.Add("xero-tenant-id", tenant.ToString());
HttpResponseMessage httpResult = client.SendAsync(requestMessage).Result;
data = httpResult.Content.ReadAsStringAsync().Result;

ViewBag.data = data;


so I do have communication.

Anyway I probably need to spend an hour or two screensharing with someone who knows what they're doing - and I'm not expecting a freebie!

Any interest?


Hi Ross, we do lots of Xero integration work, but we don't use the Xero SDK, we just roll our own HTTP requests (which are pretty easy, really). So, I can't help with your XeroClient issue, but if you like - flick an email to us at via www.blackballsoftware.com, and mention me, I'll send you through some source code in C# which will probably be helpful.

Benjamin Liebert  

Thanks for your help Benjamin - i'm up and running now!


ross woodward  

Awesome, pleased to hear it :)

Benjamin Liebert  

Hi Ross
I am finding exactly the same issues as you. Please can you share your solution that got you up and running. Would be greatly appreciated!

Kevin Efune