oracle / oci-typescript-sdk

Oracle Cloud Infrastructure SDK for TypeScript and JavaScript
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdk.htm
Other
77 stars 54 forks source link

Error on `RequestSummarizedUsages`: "OciError: Passed UTC date does not have the right precision: hours, minutes, seconds, and second fractions must be 0" #193

Closed samuelastech closed 1 year ago

samuelastech commented 1 year ago

I'm trying to use the UsageAPI but always getting this error:

samuelastech commented 1 year ago

[...]

errorObject: OciError: Passed UTC date does not have the right precision: hours, minutes, seconds, and second fractions must be 0
jodoglevy commented 1 year ago

@samuelastech can you share the code you are running which is giving you this issue?

From the error, it sounds like there is a parameter in the operation you are calling, and for that parameter you are passing a datetime value which has at least some of the following components of the datetime set to a non-zero value: hours, minutes, seconds, and/or second fractions. These components of the datetime need to be set to 0, per the error message.

samuelastech commented 1 year ago

Here is my code:

const usageDetails = {
      tenantId: provider.getTenantId(),
      granularity: models.RequestSummarizedUsagesDetails.Granularity.Monthly,
      timeUsageStarted: new Date("2023-02-02"),
      timeUsageEnded: new Date("2023-03-05"),
};

I didn't understand your explanation. I need to set datetime values to zero?

samuelastech commented 1 year ago

I solve it by using:

timeUsageStarted: new Date(Date.UTC(2022, 06, 01, 0, 0, 0, 0)),
timeUsageEnded: new Date(Date.UTC(2023, 03, 07, 0, 0, 0, 0)),