In EWS I can query a calendar with DateTime.Now and to only get the currently active events.
DateTime filterStartDate = DateTime.Now;
DateTime filterEndDate = filterStartDate.Date.AddDays(1).AddSeconds(-1);
CalendarView ccView = new CalendarView(filterStartDate, filterEndDate);
But it does not seem to work with MS Graphi API, where if the event started before my start filter, it won't show up
var queryOptions = new List<QueryOption>()
{
new QueryOption("startDateTime", filterStartDate.ToString("s")),
new QueryOption("endDateTime", filterEndDate .ToString("s"))
};
var res = await _graphClient.Users[roomSMTP].CalendarView
.Request(queryOptions)
.Header("Prefer", $"outlook.timezone=\"{_outlookTimeZone}\"")
.Select("start,end,subject,organizer,id").GetAsync();
Is this by design or am I missing some sort of filter?
Any help would be appreciated.
CodePudding user response:
From the documentation:
The values of startDateTime
and endDateTime
are interpreted using the timezone offset specified in the value and are not impacted by the value of the Prefer: outlook.timezone
header if present. If no timezone offset is included in the value, it is interpreted as UTC.
I don't know if you are trying out edge cases but maybe you should use .ToString("o")
(see here).
And do you know that your code returns IUserCalendarViewCollectionRequest
and that you need to iterate over the calendarViewPages
and get the results for every page?