XeroAPI / Xero-NetStandard

A wrapper of the Xero API in the .NetStandard 2.0 framework. Supports Accounting, Payroll AU/US, and Files
MIT License
127 stars 124 forks source link

Creating Invoice and Handle Exception #261

Closed Taity180 closed 2 years ago

Taity180 commented 4 years ago

Hi, I am migrating my existing Xero api code from OAuth 1.0 to OAuth 2.0.

Currently using

The issue that I am having is when I am using the CreateInvoiceAsync call thought the AccountingApi and I get an exception, previosuly in 2.0 I would be getting a ValidationException, but now i am only getting an Exception. The Exception type coming in is a type ValidationException, but I can't access the error messages as needed.

To Reproduce, what i have done is create a new api call using AccountingApi and CreateInvoiceAsync and i added in an Item code which doesn't exist in my Xero account. the exception will return with the error bundled inside. What i was excepting to happen was i would be able to catch a ValidationException?

Thanks

jenksguo commented 3 years ago

Hi @Taity180, thanks for raising this. It is on our SDK roadmap to improve the validation exception experience.

Just clarifying, you are expecting an .NET exception but it should also return an ValidationException object.

Taity180 commented 3 years ago

Hi jenksguo, thank you for your response, I was expecting a .NET ValidationException which is how the Xero API 1.0 would handle an error issue. The Exception that is returning now has within the InnerException which I have pushed to a Json String and have managed to extract the ValidationErrors which is where the Xero is adding any errors into and going from there.

Thanks.

JRising-Xero commented 2 years ago

Issue is resolved in latest version of SDK:

image

image