msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

[Client bug]: DeltaWithToken and DateTime format

Open JoseAngelSalmeronMorote opened this issue 6 months ago • 3 comments

Describe the bug

DeltaWithTokenRequestBuilder.DeltaWithToken(string token) not working with DateTime values that contains time.

To Reproduce Steps to reproduce the behavior:

  1. Execute a Delta query using DriveItemItemRequestBuilder.DeltaWithToken method.
  2. Include a token with DateTime format such as: '2021-09-29T20:00:00Z'
  3. See error "token malformed"

Expected behavior

Delta query should success.

Screenshots image

Client version v5.37.0 Microsoft.Graph

Additional context Based on documentation format for datetimes should be '2021-09-29T20:00:00Z' but this raises above exception. Scaping the datetime as url doesn't work either.

When removing the time from the datetime then it's working:

  • Fails: DeltaWithToken("2024-01-01T20:00:00Z")
  • Works: DeltaWithToken("2024-01-01")

Also seems to be a limitation of 2months -1day to set the DateTime value in the past. Maybe is documented elsewhere?

JoseAngelSalmeronMorote avatar Jan 05 '24 17:01 JoseAngelSalmeronMorote

Thanks for raising this @JoseAngelSalmeronMorote

The DeltaWithToken generates a url with the token as a url parameter similar to me/drive/root/delta(token='2024-01-01T20:00:00Z') while the documentation example suggests that the parameter should be a query parameter as drive/root/delta?token=2024-01-04T20:00:00Z. This is metadata issue currently tracked via https://github.com/microsoftgraph/msgraph-metadata/issues/431 as the SDK should provide the query parameter as an option.

Also seems to be a limitation of 2months -1day to set the DateTime value in the past. Maybe is documented elsewhere?

Any chance you can ask this query at the link below to get feedback from the relevant API owners? We may not be best placed to answer as this repo is mainly for SDK related isssue. https://learn.microsoft.com/en-us/answers/tags/161/ms-graph#

andrueastman avatar Jan 09 '24 09:01 andrueastman

Hi, thanks for the reply.

I've raised my question regarding datetime limit in the suggested link.

Regarding 'DeltaWithToken' vs Token parameter i would like to be sure on this point:

I though based on this post that 'DeltaWithToken' should be used instead of documented '.Token' property. Maybe 'DeltaWithToken' should only be used with 'latest' option?

So, in order to use DateTimes (date + time) the only available option is wait until '.Token' parameter is added in library, is correct?

Thanks in advance.

JoseAngelSalmeronMorote avatar Jan 15 '24 15:01 JoseAngelSalmeronMorote

So, in order to use DateTimes (date + time) the only available option is wait until '.Token' parameter is added in library, is correct?

Yes. That would indeed be the case. As highlighted in https://github.com/microsoftgraph/msgraph-metadata/issues/431, this specific api causes abit of confusion for end users. In the meantime however, you can construct a url and use the WithUrl method to override the construted url available in requestbuilders as below.

var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Delta.WithUrl("https://graph.microsoft.com/v1.0/me/drive/root/delta?token=2021-09-29T20%3A00%3A00Z").GetAsync();

andrueastman avatar Jan 16 '24 06:01 andrueastman