XeroAPI / Xero-NetStandard

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

DateTimeUTC is missing in the response object class #448

Closed thusithagh closed 1 year ago

thusithagh commented 1 year ago

Xero.NetStandard.OAuth2 3.29.1 Xero.NetStandard.OAuth2Client 1.6.0

No property to hold the DateTimeUTCwhich seems to be the request processed by the API server, in any of the response object classes in Xero.NetStandard.OAuth2.

To Reproduce Steps to reproduce the behavior:

  1. Go to API explorer

  2. Make any API request against the Demo org (eg: Accounting/GetAccounts)

  3. Notice the "DateTimeUTC" in the response image

  4. Use Xero.NetStandard.OAuth2 to make the same request.

  5. Notice that there isn't any property to hold the "DateTimeUTC" within the object class

image

Expected behavior There should be a proper DateTimeproperty to hold the DateTimeUTCreturned.

This timestamp is needed, so we don't have a mismatch between the time actually the request got processed by the API server, and the time we started requesting. Please see if we can add that property to all the response object classes.

Best regards, Thusitha H

JRising-Xero commented 1 year ago

Hi Thusitha, You can use the GetAccountsAsyncWithHttpInfo() method to retrieve this additional response data. This method will return an ApiResponse<T> wrapping the standard model you get using GetAccountsAsync(). You will find the date time under Content, note, you will have to manually parse this information, i.e. something like:

var response = await _accountingApi.GetAccountsAsyncWithHttpInfo(xeroAccessToken, xeroTenantId);
var datetime = (DateTime)JObject.Parse(response.Content.ToString()).GetValue("DateTimeUTC");

Let me know if this solves your issue or if you have any other questions :)

thusithagh commented 1 year ago

Thanks for that @JRising-Xero I'll try out and let you know.

thusithagh commented 1 year ago

@JRising-Xero That works. Thanks! However, it'd be a great help if the object classes itself had a property with this info populated.