Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Find a Developer >

Help getting started

Started by Jim Simmonds -   in Find a Developer

Can anyone assist me to get started with connecting to Xero.

The code below simply does not work, I have tried in the forum for advice, also via email support to Xero. Practically nothing in response. I am willing to pay for support, I need to get past the initial setup. It is highly frustrating as I have successfully connected our software to several other platforms through their API but this one is proving impossible, particularly in the support and documentation area's. it seems like its all over the place and incredibly inconsistent.

I am using visual studio 2017, Dot Net 4.7 and code in VB.

Dim ConsumerKey As String = "xxxxxxxxxx"
Dim ConsumerSecret As String = "xxxxxxxxxx"
Dim UserAgent As String = Environment.MachineName

Dim Consumer As IConsumer = New Consumer(ConsumerKey, ConsumerSecret)
Dim TheUser = New ApiUser() With {.Name = UserAgent}

Dim MemoryTokenStore As ITokenStore = New MemoryAccessTokenStore()
Dim BaseUrl As String = "https://api.xero.com"

Dim MyAuthenticator = New PublicAuthenticator(BaseUrl, BaseUrl, "oob", MemoryTokenStore )
Dim PublicApi = New XeroCoreApi(BaseUrl, MyAuthenticator, Consumer, TheUser, New DefaultMapper(), New DefaultMapper())

' Running the following command fails
Dim Public_Contacts = PublicApi.Contacts.Find().ToList()

Stack Trace.

ex.InnerExceptionGetType = Xero.Api.Infrastructure.OAuth.UnexpectedOauthResponseException

ex.InnerExceptionMessage = An unexpected HTTP response was returned while performing OAuth operations

ex.InnerExceptionSource = Xero.Api

ex.InnerExceptionTargetSite = Xero.Api.Infrastructure.Interfaces.IToken GetToken(System.String
Xero.Api.Infrastructure.Interfaces.IToken, System.String, System.String)

ex.InnerExceptionStackTrace = at Xero.Api.Infrastructure.OAuth.OAuthTokens.GetToken(String

baseUri, IToken consumer, String endPoint, String header)

at Xero.Api.Infrastructure.OAuth.OAuthTokens.GetRequestToken(IConsumer consumer, String header)

at Xero.Api.Example.Applications.TokenStoreAuthenticator.GetRequestToken(IConsumer consumer)

at Xero.Api.Example.Applications.TokenStoreAuthenticator.GetToken(IConsumer consumer)

at Xero.Api.Example.Applications.TokenStoreAuthenticator.GetToken(IConsumer consumer, IUser user)
at Xero.Api.Example.Applications.TokenStoreAuthenticator.GetSignature(IConsumer consumer,

IUser user, Uri uri, String verb, IConsumer consumer1)
at Xero.Api.Infrastructure.Http.HttpClient.CreateRequest(String endPoint, String method, String accept, String query)

at Xero.Api.Infrastructure.Http.HttpClient.Get(String endpoint, String query)

at Xero.Api.Infrastructure.Http.XeroHttpClient.Get TResult,TResponse (String endPoint)

at Xero.Api.Common.XeroReadEndpoint`3.Get(String endpoint, String child)

at Xero.Api.Common.XeroReadEndpoint`3.Find()
at Xero.Api.Core.XeroCoreApi.get_Organisation()
Hi Jim,

As mentioned in your other thread, I'd really like to get some more information about the unexpected response you're getting. We likely won't be able to help you without this information.

Can you please use a tool like Fiddler to inspect your web traffic so you can see what response (http status code and body) we're giving back to you?


Matthew Mortimer (Xero Staff)