Search code examples
microsoft-graph-apioutlook-restapi

Microsoft Graph get calendar entries happening today (reaching over timeframe)


I'm currently struggeling with the Microsoft Graph REST-API.

What I'm trying to do is list todays events (happening between midnight and midnight). From the documentation, the filter function is very limited.

My current statement looks like this:

https://graph.microsoft.com/v1.0/me/events?$top=100&$select=*&$filter=start/DateTime ge '2017-10-31T00:00:00' AND end/DateTime le '2017-11-1T00:00:00'&$orderby=start/DateTime ASC

The interesting part is here $filter=start/DateTime ge '2017-10-31T00:00:00' AND end/DateTime le '2017-11-1T00:00:00' using the start and the end and checking if start >= TODAY AND end <= TODAY+1. That's all working great for dates that are shorter as 1 day.

My problem is now how to get events that last longer than one day e.g. start = YESTERDAY and end = NEXT WEEK. Which means the start date is before today and the end day is as well not included in this range.

How to get this events?


Solution

  • I believe you should be using Calendar View for your scenario: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/calendar_list_calendarview