I noticed some strange behaviour with the calendar API endpoint for shared calendars. This seems related to pagination (using $top
and $skip
) and occurs when there are deleted events.
For my account it is possible to reproduce the issue as follows:
- My main account has access to a shared calendar with
SHARED_CALENDAR_ID
and I can access events on the following endpoint: https://graph.microsoft.com/v1.0/me/calendars/[SHARED_CALENDAR_ID]/events
- Starting with a completely empty calendar (all events removed), I now create 3 events through the regular Outlook GUIs. Events have subject "Test1", "Test2", "Test3"
- Calling the endpoint with parameter
$top=2
will now return the top 2 events on the first page (e.g. "Test3" and "Test2"). The result also includes an URL @odata.nextLink
to the next page of results (with appended parameter $skip=2
). Calling this URL returns the last event "Test1", as expected.
- Now the weird thing happens when I delete one of the events (e.g. delete "Test2").
- Now I call the endpoint again with
$top=2
, this returns both remaining events ("Test3" and "Test1" as expected), but it also includes the @odata.nextLink
property. Clicking this returns a duplicate event "Test1" which was already retrieved previously.
This becomes very messy very quickly with calendars that contain many events and deleted events. Now my handling code needs to be aware of duplicates, requiring extra processing and unnecessary API calls to retrieve all events. For my account it only seems to occur for shared calendars. I'm wondering whether this is a bug? Have other people encountered this? Any advice how to further troubleshoot or deal with this issue?