I forgot to add the header:
var events = await _graphServiceClient.Users[emailAddress]
.Events
.Request()
.Header("Prefer","outlook.timezone=\"W. Europe Standard Time\"")
.GetAsync();
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am working with the Graph API and trying to create events using the C# Microsoft.Graph API. Let's assume to have the following Microsoft.Graph.Event objects:
{
Subject = "A Title",
Body = new ItemBody(),
Start = {
DateTime = "2022-10-24T00:00:00",
TimeZone = "W. Europe Standard Time"
},
End ={
DateTime = "2022-10-25T00:00:00",
TimeZone = "W. Europe Standard Time"
},
IsAllDay = true,
},{
Subject = "B Title",
Body = new ItemBody(),
Start = new DateTimeTimeZone {
DateTime = "2022-10-28T13:30:00",
TimeZone = "W. Europe Standard Time"
},
End = new DateTimeTimeZone {
DateTime = "2022-10-28T16:45:00",
TimeZone = "W. Europe Standard Time"
},
IsAllDay = false,
}
They are successfully written into my calendar trough twice call to:
await _graphServiceClient.Users[emailAddress].Events.Request().AddAsync(graphEvent);
and I see:
and
which is the expected behaviour.
Querying the API with the filter "start/dateTime ge '2022-10-24T00:00:00'" I get just B Title, A Title is missing. Furthermore the start and end dates are wrong, I get 2022-10-28T11:30:00.0000000 and 2022-10-28T14:45:00.0000000.
If I edit the query to "start/dateTime ge '2022-10-23T00:00:00'" I get both, the dates of B title are the same (wrong), but the ones of A Title ar correct 2022-10-24T00:00:00.0000000 and 2022-10-25T00:00:00.0000000.
I expected that B Title has 2022-10-28T13:30:00.0000000 and 2022-10-28T16:45:00.0000000. What am I doing wrong?
I forgot to add the header:
var events = await _graphServiceClient.Users[emailAddress]
.Events
.Request()
.Header("Prefer","outlook.timezone=\"W. Europe Standard Time\"")
.GetAsync();