Giter Site home page Giter Site logo

xero-net's Introduction

Xero-Net

Looking for OAuth 2.0?

Please checkout Xero-NetStandard SDK for OAuth 2.0 and one of it's starter projects. Xero-NetStandard starter for .NET Core or Xero-NetStandard starter for .NET Framework 4.6.1 and higher

Xero-Net for OAuth 1.0a Deprecated as of April 2021

As of April 2021, Xero is deprecating support for OAuth 1.0a. If you need more time to complete your migration to OAuth 2, please contact [email protected] for assistance.

We are archiving this repository. For those wishing to use Xero-Net going forward you have the option of forking the Xero-Net repository. We recommend moving to Xero-NetStandard SDK for OAuth 2.0 as it will be supported and maintained going forward.

xero-api-sdk MyGet Build Status Build status

A skinny wrapper of the Xero API. Supports Payroll. All third party libraries are included as source code.

Installation

There are different way to install this library:

  1. Download the source code from github and compile yourself: https://github.com/XeroAPI/Xero-Net
  2. Download directly into Visual Studio using the NuGet powershell command PM> Install-Package Xero.API.SDK.Minimal to get a minimal installation.
  3. Download directly into Visual Studio using the NuGet powershell command: PM> Install-Package Xero.API.SDK to get a larger installation with sample token store using SQLite.

What is supported?

Core

  • Accounts - Create, Find and Update
  • Attachments - Add, Get and List
  • Bank Transactions - Create, Find and Update
  • Bank Transfers - Create and Find
  • Branding Themes - Find
  • Contacts - Create, Find and Update
  • Credit Notes - Create, Find and Update
  • Currencies - Find
  • Employees - Create, Find and Update
  • Expense Claims - Create, Find and Update
  • Invoices - Create, Find and Update
  • Items - Create, Find and Update
  • Journals - Find
  • Manual Journals - Create, Find and Update
  • Organisation - Find
  • Payments - Create, Find and Update
  • Purchase Orders - Create, Find and Update
  • Receipts - Create, Find and Update
  • Repeating Invoices - Find
  • Reports - Find
  • Setup - Create and Update
  • Tax Rates - Create, Find and Update
  • Tracked Inventory - Create and Update Tracked Inventory Items. Purchase, sell, and adjust inventory
  • Tracking Categories - Create, Find and Update. Add, Update and Remove TrackingOptions
  • Users - Find

Australian Payroll

  • Employees - Create and Find
  • Leave Applications - Create and Find
  • Pay Runs - Create and Find
  • Payroll Calendars- Create and Find
  • Pay Slips- Create and Find
  • Settings - Find
  • Super Fund Products - Find
  • Super Funds - Create and Find
  • Timesheets - Create and Find

United States Payroll

  • Employees - Create and Find
  • Pay Runs - Create and Find
  • Pay Schedules - Create and Find
  • Pay Stubs- Create and Find
  • Settings - Find
  • Timesheets - Create and Find
  • Work Locations - Create and Find

Files API

  • Files - Find, Add, Rename, Move, Remove and Get Content
  • Folders - Find, Add, Rename and Remove
  • Inbox - Find

Things to note

  • The library tries to do as little as possible and provides a basis to be extended. There are examples of TokenStores, Authenticators and Application types. These examples provide enough to get you going, but are not a complete solution to all your needs. You will need to adapt them for your own use and situation. Private application will work out of the box, as they do not have to deal with tokens and OAuth.
  • The HTTP verbs are not used in the public part of the API. Create, Update and Find are used instead. This separates the implementation from the intent.
  • Some accounting endpoints support pagination. In the RESTful API these are off by default. For the wrapper, they are always on and default to page 1. See the Counts or Creation code examples for how to use the Page method to get all items.
  • Contacts support including archived contacts. Like the RESTful API, this if off by default. Use IncludeArchived(true) to include them.
  • Payroll supports paging on all endpoints.
  • Four decimal places are supported and are always on.
  • You will need an instance of the API per organisation / connection. The connection is stored as part of the API instance.
  • Query parameters are cleared after each operation on an endpoint. If you use Invoices.Where("Type == "ACCREC"").Find() when querying invoices for example, the next Invoices.Find() will not retain the where clause query parameter.

Samples

There are samples for each of the API endpoints. These have been done as console application and also a collection of NUnit tests. See the README for each of the executable and test assemblies. The test projects contain lots of useful examples of how to use this library to interact with the Xero API.

Querying

There are simple filters on different endpoints.

  • ModifiedSince
  • Where
  • Or
  • And
  • OrderBy
  • OrderByDescending
  • Page
  • Offset

They are used in a Fluent way, but are not LINQ. They simply create a query for the URL passed to the API. Nested queries are not handled using the syntax. Or and And need to come after a Where statement. OrderBy, OrderByDescending and Page can come anywhere.

var invoices = xeroApi.Invoices  
	.ModifiedSince(new DateTime(2014, 1, 31))  
	.Where("Total > 3500.0")  
	.And("Total < 10000.0")  
	.Page(2)  
	.OrderByDescending("DueDate")  
	.Find();

The following gives the same query string to the API as the example above.

var invoices = xeroApi.Invoices  
	.Page(2)  
	.OrderByDescending("DueDate")  
	.Where("Total > 3500.0")   
	.And("Total < 10000.0")  
	.ModifiedSince(new DateTime(2014, 1, 31))  
	.Find();

Application types

There are specific classes for each of the application types. If these are used, you will need to have the app.config file settings for your organisation.

For a public application you would use

var user = new ApiUser { Name = "The users name" };
var tokenStore = new SqliteTokenStore();

var api = new Applications.Public.Core(tokenStore, user)
{
    UserAgent = "Something to show your application"
};

The config file will look like this

<add key="BaseUrl" value="https://api.xero.com"/>
<add key="ConsumerKey" value="Your Key"/>
<add key="ConsumerSecret" value="Your secret"/>
<add key="CallbackUrl" value="Your callback"/>

There are classes for Private, Public and Partner applications for the Core Xero API and Australian and American Payrolls.

A private application will need to also populate

<add key="SigningCertificate" value="Path to .pfx file"/>

A partner application will need to also populate

<add key="SigningCertificate" value="Path to .pfx file"/>

Authenticators

The application classes all use implementations of IAuthenticator. See PrivateAuthenticator for an example. The authenticators are used by the base infrastructure to do the heavy lifting of the Xero API authentication.

PrivateAuthenticator

Uses RSA-SHA1 and a public/private certificate. There are no tokens and each request has to be signed.

PublicAuthenticator

Uses HMAC-SHA1 and the standard 3-legged OAuth process. Tokens last for 30 minutes and cannot be renewed.

PartnerAuthenticator

Uses RSA-SHA1 and then the standard 3-legged OAuth process with an additional signing certificate. Tokens last for 30 minutes and be renewed. Token renewal is supported by this provider.

Examples for renewing your access tokens can be seen in the RenewToken method overrides in the PartnerAuthenticator.cs and PartnerMVCAuthenticator.cs classes.

OAuth signing

All the signing is done by a slightly modified version of the Dust library provided by Ben Biddington. Source is included.

Token Stores

The token store implementations are separate and optional. (It is recommended that you do have a store.)

The interface ITokenStore has three methods.

public interface ITokenStore
{
	IConsumer Find(string user);
	void Add(IToken token);
	void Delete(IToken token);
}

You can provide your own implementation to suit the database you are using for your product. Ensure the dates on the token are stored in UTC.

The examples are

  • MemoryTokenStore - Dictionary of token in RAM keyed on UserId
  • SqliteTokenStore - A database of tokens (file on local disk). This does not support multiple add-ons in the same database. The tokens are only for the application the database was created by.

Serialization

All communication with the Xero API is compressed at source. Writing to the API is done with XML. The data model classes have be attributed to give a small XML payload. All communication back from the API is JSON. These details are transparent to the user of the class library.

Usage

To get going quickly:

  1. Follow this getting started guide: http://developer.xero.com/documentation/getting-started/getting-started-guide/
  2. Create a console project and download the following package using the NuGet powershell command: PM> Install-Package Xero.API.SDK
  3. Use the snippets below depending on the type of application, modifying keys and certificate paths.

Note, remember to implement your own custom token store before going live. The examples provided in the library Xero.Api.Example.TokenStores.dll are for development only.

static void Main(string[] args)
{
	// Private Application Sample
	var private_app_api = new XeroCoreApi("https://api.xero.com", new PrivateAuthenticator(@"C:\Dev\your_public_privatekey.pfx"),
        new Consumer("your-consumer-key", "your-consumer-secret"), null,
        new DefaultMapper(), new DefaultMapper());

	var org = private_app_api.Organisation;

	var user = new ApiUser { Name = Environment.MachineName };

	// Public Application Sample
    var public_app_api = new XeroCoreApi("https://api.xero.com", new PublicAuthenticator("https://api.xero.com", "https://api.xero.com", "oob",
		new MemoryTokenStore()),
        new Consumer("your-consumer-key", "your-consumer-secret"), user,
        new DefaultMapper(), new DefaultMapper());

    var public_contacts = public_app_api.Contacts.Find().ToList();

	// Partner Application Sample
	var partner_app_api = new XeroCoreApi("https://api-partner.network.xero.com", new PartnerAuthenticator("https://api-partner.network.xero.com",
        "https://api.xero.com", "oob", new MemoryTokenStore(),
        @"C:\Dev\your_public_privatekey.pfx"),
         new Consumer("your-consumer-key", "your-consumer-secret"), user,
         new DefaultMapper(), new DefaultMapper());

	var partner_contacts = partner_app_api.Contacts.Find().ToList();			
}

Acknowledgements

Thanks for the following Open Source libraries for making the wrapper and samples easier

License

This software is published under the MIT License.

Copyright (c) 2016 Xero Limited

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

xero-net's People

Contributors

cbs-greg avatar chappoo avatar corientdev avatar ezescan-rhys avatar fnakashima avatar gerald-abacus avatar ian-hook avatar jamescolemanxero avatar justabearoz avatar kiwidave72 avatar lukekirbydg avatar matthewsteeples avatar mattliuoz avatar mjava1 avatar mjmortimer avatar mronosa avatar mrrrk avatar orthros avatar philals avatar richard-rowley avatar rileyjamesxero avatar rohitsies avatar ronanq avatar ronnyek avatar shaun5004 avatar sidneyallen avatar tamaw avatar thevalyreangroup avatar uptimecomputing avatar vyasnirav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xero-net's Issues

NuGet Package Version

Hi all,

Currently there is no way to correlate the change history in GIT with the version published to NuGet (https://www.nuget.org/packages/Xero.API.SDK/).

Would it be possible to include the GIT commit hash that was built in the package metadata somewhere? (Either that or release notes, but automation is always better...:)). This would provide some transparency as to where the package is at. I know it's technically possible, but I'm not sure how the package / publish process is setup; i.e. you can inject custom properties into the nuget.exe pack command.

Thanks
Steve

NuGet package dependency SQL Lite?

Why does the Xero.API.SDK package now pull a dependency on System.Data.SQLite (and itself, another 3 dependencies) when they're not required by the core wrapper dll? (introduced in change 1c17666). I've just updated to the latest package version (2.0.5) and now I'm forced to take a dependency on all these other dependencies, which are completely unnecessary to satisfy full run-time closure of our app. I have to state an objection to this, as most of the users will not be requiring the examples. This also slows down builds, which isn't good.

It looks like it's there because, for some reason, the package is bundled with the examples. I'd have thought a better way of packaging this is to pack the examples into another package (Xero.API.SDK.Examples perhaps) which itself has a dependency on the Xero.API.SDK package. Or flip-side pull the core wrapper dll into a dependency free package and do the opposite. Either way, much better than forcing your customers to install packages they don't need.

Please consider doing this, it will save headaches for consumers in the future.

Regards
Steve

Type of CurrencyRate is inconsistent

CurrencyRate is sometimes nullable and sometimes not. Ideally it should be the same across the board, but I'm not sure which is correct.

Nullable

  • Invoice
  • Overpayment
  • Prepayment

Regular

  • BankTransaction
  • BankTransfer
  • CreditNote
  • Payment

Consistency of Naming LineItems across Core Models

I noticed a naming consistency issue for how LineItems are called.

The Receipt, BankTransaction, CreditNote, RepeatingInvoice all have the LineItems lists called LineItems:

public List<LineItem> LineItems { get; set; }

While the Invoice Class is called Items:

public List<LineItem> Items { get; set; }

I suggest we change Invoice LineItem list to be LineItems as well in order to be consistent across classes.

Callback support removed from example authenticators?

In the latest change-sets it looks like support for callback urls has been removed. Just wondering why this was done; are we supposed to maintain our own authenticator / signing code; as it's a core requirement to need the callback when used in the wild?

A bit of clarity around the intended consumption pattern of the wrapper would be much appreciated.

Thanks
Steve

ValidationErrors

Hi, this is more of a question or request than a bug.
Is there any way to see on which invoice the validation errors returned in a validation exception are thrown, it only shows a list with no way of identifying the failed ones.

NuGet Update

I noticed a Pull Request that adds support for the key changes to the OverPayments endpoint. Do you have an ETA for the update to be published to NuGet?

Thanks,
Steve

Callbackurl

I am trying to use call back URL. Here i am not able to see any way to implement the call back URL. In the GetRequestToken method there is no parameter to set the call back URL. Can you please tell is there any way to implement using call back URL.

Should OAuthException be internal?

We're seeing cases where OAuthException (and UnauthorizedException) are being thrown, but no way to explicitly catch it because the exception is internal. If its internal, does it get re-thrown as something public elsewhere?

Payment terms DAYSAFTERBILLMONTH not converted correctly

When I set the default bill payment terms for a contact in Xero e.g. to 20 days after the end of the bill month, the .Net wrapper does not seem to translate the payment terms correctly. In my application I receive PaymentTermType FollowingMonth, but I expect AfterInvoiceMonth.

I had a look at the online API previewer and the payment terms returnd for my example contact is "DAYSAFTERBILLMONTH", but the corresponding enum is called "DAYSAFTERINVOICEMONTH" in PaymentTermType.cs.

AustralianPayroll.Timesheets.Where doesn't appear to work

Attempting to do AustralianPayroll().Timesheets.Where("StartDate > 0") for example returns:

An exception of type 'System.Runtime.Serialization.SerializationException' occurred in Xero.Api.dll but was not handled in user code

Additional information: Type definitions should start with a '{', expecting serialized type 'ApiException', got string starting with: <Response xmlns:i="http://www.w3.org/2001/XMLSchem

AustralianPayroll().Timesheets.Find() returns Timesheets as expected.

Any advice would be appreciated. Thanks.

API Development

I noticed there have been no commits to this repository since 05/09/2014: e338a31 however there have been 6 minor releases of the XERO API since then. Is this repository still under active development?

Happy to get involved in helping to maintain the API (we're already using the .NET wrapper), need to know up front though if the effort is worth it.

TotalDiscount on invoices appears to be missing

Hi,

The TotalDiscount value appears to be missing from the wrapper, but is available on the API. I wasn't sure on the best way to implement this without forking the code and adding it in myself, but would prefer to use the Nuget package in the production code.

Quote & Purchase orders via API

Hi,
What is the latest news on Quotes and purchase orders via the API? Is there a timeframe for them to be up and running?
Thanks

Remove System.Web Reference

I tried using the API with a .Net 4.0 Client Profile application and it failed due to the reference to System.Web, which is not part of the Client Profile. I searched the code and found the only use of System.Web is three occurrences of HttpUtility.ParseQueryString.

You can replace HttpUtility.ParseQueryString with a custom function in order to remove the System.Web reference, which will allow the API to work with Client Profile installs out-of-the-box.

Here is an example of replacing HttpUtility.ParseQueryString with a custom function.

http://densom.blogspot.com.au/2009/08/how-to-parse-query-string-without-using.html

HTTP 407.3 forbidden errors with PartnerAuthenticator

I've been trying to get our API working using partner oauth and have had no success; getting continual forbidden errors.

HTTP Error 403.7 - Forbidden
The page you are attempting to access requires your browser to have a Secure Sockets Layer (SSL) client certificate that the Web server recognizes.

I've read that partner oauth should now be working, here's the code I'm using:

        var partner_app_api = new XeroCoreApi("https://api-partner.network.xero.com", new PartnerAuthenticator("https://api-partner.network.xero.com",
                    "https://api.xero.com", "oob", new MemoryTokenStore(),
                    @"Z:\Steve\SparkleShare\public_privatekey.pfx",
                    @"Z:\Steve\SparkleShare\entrust.p12",
                    "password for entrust cert"),
                     new Consumer("key", "secret"), user,
                     new DefaultMapper(), new DefaultMapper());

        var partner_contacts = partner_app_api.Contacts.Find().ToList();
        partner_contacts.PrintDump();

To be honest, I get a bit confused with the documentation around the certificates and what they're 'called', but the above certificates are:

Z:\Steve\SparkleShare\public_privatekey.pfx = the one created here http://developer.xero.com/documentation/advanced-docs/public-private-keypair/

Z:\Steve\SparkleShare\entrust.p12 = the one I downloaded from entrust

All the details in 'My Applications' look to be setup correctly, and the public cert is a valid one generated using public_privatekey.pfx.

Windows Azure Partner Application

Hi,

I am running my app using the Windows Azure cloud. I have some questions about XeroApiHelper.cs:

  1. What code must be modified to run this solution in the Windows Azure cloud?
  2. Do I need a signingCertificatePath and a clientCertificatePath?
  3. How do I obtain the signingCertificatePath? I see code on splitting the P12 Entrust SSL certificate. Is this how I obtain it? I added the P12 file to MMC and then I exported it. I received a PFX file. Is that what I need?
  4. When I run the solution locally, I see this error:

The specified network password is not correct.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: The specified network password is not correct.

Source Error:

Line 80: var partnerConsumer = new Consumer(partnerConsumerKey, partnerConsumerSecret);
Line 81:
Line 82: var partnerAuthenticator = new PartnerMvcAuthenticator(basePartnerApiUrl, baseApiUrl, callbackUrl,
Line 83: memoryStore, signingCertificatePath, clientCertificatePath, clientCertificatePassword,
Line 84: partnerConsumer, requestTokenStore);

http://developer.xero.com/documentation/getting-started/partner-applications/#certificates

Xero.Api.Infrastructure.Http.Response Initialization

Serveral methods in Xero.Api.Infrastructure.Http.HttpClient class do create Response object in case of an exception, by casting WebExceptionResponse...

However, in some cases, Response property of WebException object is a null reference:
For instance, In case api.xero.com is not reachable, a SocketException is being thrown, and because WebException.Response is null in such case, line
return new Response((HttpWebResponse)we.Response);
throws an exception of its own (NullReferenceException) from within the constructor of Response class.

Xero Files API - Folders

  1. Folder model returns list of folders instead of list of files
  2. Folders endpoint doesn't implement Update properly
    • whenever I tried to call the Update method, it keeps on returning Bad Request even though the object I'm passing (Folder Id and new name), I believe, is valid

Crete Item as IsTrackedAsInventory

Hi,

I am trying to create a new item as IsTrackedAsInventory and InventoryAssetAccountCode. Your item object does not have these fields. If I add them, will it work?

TimesheetLine missing EarningsTypeId Property

According to Xero Support, the correct field for posting a US Timesheet is EarningsTypeId and not EarningsRateId.

Xero Network & Developer API - ticket number 2593298

Hi XXXXXX,
THe US payroll uses, EarningsTypeID and not EarningsRateID. Although the XML elements explained under 'the Elements for TimesheetLines' shows it correctly as EarningsTypeID the sample XML provided has EarningsRateID and hence the confusion. We've update our documentation to reflect the correct TimesheetLines element. Please give it a try with it and let us know.
Sorry for the the inconvenience caused.
Regards,
Krish

This is fine, however there is no EarningsTypeID property on the TimesheetLine Model.

Reports.BalanceSheet - BadRequestException: Report Parameter date could not be parsed as a DateTime

Following code:

var api = XeroApiHelper.CoreApi();

var report = api.Reports.BalanceSheet(new DateTime(2016, 3, 31));
Xero.Api.Infrastructure.Exceptions.BadRequestException was unhandled by user code
  ErrorNumber=10
  HResult=-2146233088
  Message=Report Parameter date could not be parsed as a DateTime
  Source=Xero.Api
  Type=ValidationException
  StackTrace:
       at Xero.Api.Infrastructure.Http.XeroHttpClient.HandleErrors(Response response)
       at Xero.Api.Infrastructure.Http.XeroHttpClient.Read[TResult,TResponse](Response response)
       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(String child)
       at Xero.Api.Core.Endpoints.ReportsEndpoint.BalanceSheet(DateTime date, Nullable`1 tracking1, Nullable`1 tracking2, Boolean standardLayout)
       at UI.Xero.XeroController.Reports() at C:\Projects\Taxes\Taxes.UI\Xero\XeroController.cs:line 71
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
  InnerException: 

LineItem AccountCode

I've created a list of items in Xero, with filled Sales and Purchase details, in order to rely on default account codes (tax rates) per line item for each new Invoice. So, when creating a new invoice, for each line item I set a proper ItemCode value. However, I was getting "BadRequest" error every time. It turned out that, when AccountCode was not set explicitly, default value is taken, so the actual generated XML contains the following line, for each line item

which causes an error. And this is due to Attribute in LineItem class.

[DataMember]
public string AccountCode { get; set; }

(default value - null - gets used). Changing previous Attribute to

[DataMember(EmitDefaultValue = false)]

fixes the issue, and new invoice gets created with appropriate tax rate. If attribute is set up as it is on purpose, please let me know.

Thank you

OAuth problem when uploading attatchement to invoice

I am getting the following error when trying to attach a pdf document to an invoice.
oauth_problem=signature_invalid
oauth_problem_advice=Failed to validate signature

Here is the code that I am trying to run:

Xero.Api.Core.Model.Attachment attachment = new Xero.Api.Core.Model.Attachment(stream, fileName, "application/pdf", fileSize);
_repository.Attachments.AddOrReplace(attachment, Xero.Api.Core.Model.Types.AttachmentEndpointType.Invoices, invoiceAccRef);

My program is targeting .Net 4.5 and is using a PrivateAuthenticator in the XeroCoreApi constructor. I have been using the api fine to create invoices and credit notes as well as sync contact and organisation information with my local database.

Apologies if I'm simply not using the api correctly. Any help much appreciated.

Renew token

Hi,

I am able to connect and retrieve some datas with the partner application, however, I cannot make the token renew after 30 min and frankly, I do not know how to do that. I have spent a lot of time to find out, but no luck so far. Can anyone show me a way to renew the token once it gets expired without redirecting the end-user through the website to authorise it.
I appreciate your time and help.

In addition, I am using the web form, however, I am able to use the MVC Authentication method in it.

rate limit exceeded

Please handle "rate limit exceeded" better than merely saying stream error

Missing creditnotes in Invoice object

According to the API documentation an creditnotes element is passed along with an invoice. However in this version of the XeroAPI it is missing in the invoice object. The element still exists in the API Previewer. I think someone forgot this to add in the new XeroAPI since it exists in the old one.

OAuth problem with private application

  1. Launching Xero.Api.Example.Counts for public application โ€“ everything works fine.
  2. Registered private application
  3. Added .cer file, generated .pfx and replaced it
  4. Changed ConsumerKey, ConsumerSecret
  5. After launching this error appears:
    oauth_problem=consumer_key_rejected&oauth_problem_advice=Private%20applications%20cannot%20request%20a%20Request%20Token

Payroll - issues

As reported by a user:

  • In Xero-Net for, the end point for payslips is payroll.xro/1.0/Payslips
  • A payslip will not Deserialize to the Payslip object after returning a successful JSON request

XML Comments

More of a request then an issue but could you add XML commenting, please? In my opinion It would make it a lot easier for developers to work with the API. Thank you

BankStateBranch is an integer field - should be a string

The BankStateBranch property on a number of objects (including Employee in the Australian Payroll API) is an integer. However, when a BSB number has a leading 0 (e.g. 012345) and is converted to an integer, the leading 0 is dropped. This then results in the validation error "BSB requires 6 digits" in the response. This property should be a string instead of an integer.

As a side note, there doesn't seem to be a way to get what the validation errors are from the exception. It would be useful to have this information for logging purposes in production. I had to identify this problem using Fiddler and inspecting the JSON response.

Account Updating

Hi,
We're using the Xero API to sync account data but currently only the Status of an account can be updated. Do you have a timescale for when more fields will become available for update via the API?
Thanks

Can we get a version that works with .Net 2.0?

I know this is a big ask but one of my client needs to authenticate with Xero but they are at this time unable to upgrade their systems. Its a massive system. Any chance we can get a version that would work with 2.0? Or maybe get some help some where?

Thanks in advance

Token_rejected with Private Authentication.

It seems to me the current version has not been tested with private authentication.
This is because I had to make the changes that Jim suggests
https://community.xero.com/developer/discussion/6639946#answer7836808
including changing Public.Core to become Private.Core

After making these changes I progressed further, however I am now receiving a Token_rejected error
however I doing think it a fault with the actual token access because I can authenticate using an old test application that I have.

However I simply cant get this code working with private authentication.

I have tried the suggestion at #31 but it hasn't helped me.

I am using .Net framework 4.5

I think whether the problem has to do with the api.UserAgent property which gets set in the code to "Xero Api - Listing example" , which doesn't seem appropriate for private authentication

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.