Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

Xero-NetStandard-OAuth2 - CreateInvoicesAsync - how to handle exceptions

Started by Gerard D'Rozario -   in Wrapper libraries

How do we deal with exceptions to functions such as CreateInvoicesAsync?

try{
var response = await CreateInvoicesAsync(...);
}
catch ( Exception ex)
{
....
}

I send a batch of invoices, one of them may have an invalid Date for example, which will throw an exception. And I presume the whole batch gets rejected?

So I ideally want to examine the validation errors in the catch using json serialization, remove the invoice with bad data and re-submit the batch.

Thanks! Gerard
Hey Gerard, if you use the summarisedError = false flag in this call, you will be able to get 200 and the error array corresponding the failed ones. The rest will go through. :-)

Let me know how you go.

On your developer portal has a logging feature called "history". You can use it to check inspect your request and response. :-)
 

Jenks Guo (Xero Staff)  

Thanks mate. That fixed my issue!
 

Gerard D'Rozario