XeroAPI / Xero-NetStandard

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

Null Responses Returned From AccountingApi Client #507

Open phil000 opened 3 months ago

phil000 commented 3 months ago

SDK you're using (please complete the following information): Xero.NetStandard.OAuth2 4.0.1 Xero.NetStandard.OAuth2Client 1.6.0

Describe the bug We have been using the Xero.NetStandard.OAuth2 packages for several years to integrate with Xero with no real issue. In the last 2 months or so various API's have been returning a null 'response'. We would not expect that. If the API call is successful we'd expect the response object back, otherwise if it is not successful we'd expect an exception telling us the issue. This issue does not happen all the time, but happens occasionally, like twice a week.

Additionally, we have several customers that we integrate with Xero for using a Custom Connection, and the issue occurs across these different customers\connections.

e.g. This call can occasionally return a null 'response'

XeroModel.Attachments response = await _accountingApi.CreateInvoiceAttachmentByFileNameAsync(AccessToken, TenantId, guid, filename, fileData, includeOnline: true);

e.g. This call can occasionally return a null 'response'

XeroModel.Invoices response = await _accountingApi.CreateInvoicesAsync(AccessToken, TenantId, invoices);
  1. Does a null response indicate success or failure?
  2. How do we tell what the actual issue is if the response is null?
  3. Is there any log where we can review historical incidents to see the cause?
github-actions[bot] commented 3 months ago

PETOSS-404

github-actions[bot] commented 3 months ago

Thanks for raising an issue, a ticket has been created to track your request

phil000 commented 3 months ago

Here is when it has occurred, in the last 30 days:

2/20/2024, 10:12:07.3756086 AM (Local time) 2/28/2024, 7:26:24.4069928 AM (Local time) 2/28/2024, 7:27:14.9976902 AM (Local time) 2/29/2024, 6:00:58.8381496 PM (Local time) 3/5/2024, 7:43:04.2017037 AM (Local time) 3/14/2024, 10:32:45.7978562 AM (Local time) 3/14/2024, 10:38:54.6725353 AM (Local time)

phil000 commented 3 months ago

Possibly the issue here? In DefaultExceptionFactory if the status code is 0 you get null returned.

I've see this happen (0 status code) when the issue is in the .Xero.NetStandard.OAuth2.Client.ApiClient itself.

image

phil000 commented 3 months ago

So we've started using the client methods ending in "WithHttpInfo" to gather a bit more information from the returned ApiResponse.

What we see when null is returned is that the ApiResponse StatusCode is 0, and the ErrorText is "The operation was canceled".

Response StatusCode: 0 Response ErrorText: The operation was canceled. Response Body:

Looks like a client side timeout is causing the DefaultExceptionFactory to return null.