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

TemporaryAccessPassMethods : Invalid StartDateTime depending on local computer timezone

Open rogaxentys opened this issue 1 year ago • 3 comments

Describe the bug

I'm trying to create a temporary access pass (TAP) for a user and specify the start date time of the TAP but I get the following error message : "One or more errors occurred. (Invalid StartDateTime specified. It can not be a time in the past.)"

My local time zone is UTC +1 (Brussels). If I add an offset of 7 hours (less doesn't work), the TAP is created successfully but the activation date is 7 hours from now. If I set my local computer time zone to something else without an offset, I have the same error message. If I set my local computer time zone to UTC -6 and add an offset of 7 hours, the TAP is created and the activation date is now correct. If I manually specify the time to be "Now + 5 minutes", I have the same error message. If I manually specify the time to be "Now + 7 hours", it works but with activation date in 7 hours.

Expected behavior

A temporary access pass should be created for the user with an activation time/date matching the specified DateTimeOffset.

How to reproduce

DateTimeOffset startDateTime = DateTimeOffset.Now; var requestBody = new TemporaryAccessPassAuthenticationMethod { StartDateTime = startDateTime, LifetimeInMinutes = 60, IsUsableOnce = false, };

using (var task = Task.Run(async () => await graphClient.Users[currentUserID] .Authentication .TemporaryAccessPassMethods.PostAsync(requestBody))) { while (!task.IsCompleted) Thread.Sleep(200); if (task.IsFaulted) { return task.Exception.Message; } return task.Result.TemporaryAccessPass;

SDK Version

5.59.0

Latest version known to work for scenario above?

No response

Known Workarounds

Set your local computer's time zone to [Your time zone -6] and add an offset of +7 hours.

Debug output

Click to expand log ```

Exception thrown: 'Microsoft.Graph.Models.ODataErrors.ODataError' in System.Private.CoreLib.dll

</details>


### Configuration

Windows 11, x64

### Other information

_No response_

rogaxentys avatar Oct 24 '24 12:10 rogaxentys

This is still an issue

masonwolff avatar Nov 22 '24 20:11 masonwolff

have the same issue.

alvicode avatar Sep 15 '25 10:09 alvicode

We're also seeing the same issue. FWIW, we don't see this issue when using Graph Explorer (HTTP) or PowerShell. Only when using C# (haven't tried the other Request methods).

GuillaumeLaquerriere avatar Sep 15 '25 21:09 GuillaumeLaquerriere