Reputation: 91
I'm currently working on a Exchange Online integration project where we are using the Microsoft Graph API 1.0 to replicate the user's calendars to our system. It has been working fine so far but today I ran into a problem that I cannot solve:
How do you keep track of deletions of occurrences of recurring calendar events?
I have tried to work with 'Delta' links without success. Those requests only returns the series master together with all remaining occurrences.
E.g. First request:
GET /v1.0/users/dc7f4032-5f30-4441-a165-428aed9fb471/calendarview/delta?startdatetime=2019-04-11T00:00:00&enddatetime=2019-04-28T23:59:59
Then I request the nextLink so that I get the deltaLink, and then I request the deltaLink:
GET /v1.0/users/dc7f4032-5f30-4441-a165-428aed9fb471/calendarview/delta?$deltatoken=uwMsonT1N46Me49CO...(etc.)
Then I get the response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(event)",
"@odata.deltaLink": "https://graph.microsoft.com/v1.0/users/dc7f4032-5f30-4441-a165-428aed9fb471/calendarview/delta?$deltatoken=uwMsonT1N46Me49COq9SDw0t_wB0xaeZEqH3MS63rea577XfZFFdjg0jwU6FzfSp9LnqeqbpBGm2ppJDuDiIP280MEFjk2Q9GYyNNdCAP__CjSKSGFQ9WKmL3TPyFeXhhYE9KgmWHF1cSrx7OYBT7zPrgwY0x5peeyjBEtqkAueuE2Pb8DH4iODU-vAp-lHVOzPmkkjNyef1NTNkgNv-kg.oOHzptXCwEphbnI7YFO7saexZ_c0hZj1a0o4ZjluzUU",
"value": []
}
Subsequent calls to the deltaLink will continue to return: "value": [] as long as nothing has changed in the calendar.
Then I delete one of the occurrences in a series and then request the deltaLink again and then the MS Graph API only returns the master together with all remaining occurrences within the original timespan, without any trace of the deleted occurrence!
Anyone out there that has experience the same problem?
Upvotes: 7
Views: 1385
Reputation: 510
I'll detail my implementation in the hope that it helps:
First: our backend is node, and we use the MSGraph node client for all API requests, which is worth mentioning as I am detailing some npms we use.
/me/calendarView/delta?startdatetime=${startDate}&enddatetime=${endDate}
. Note: this is for the initial sync -- use the nextLink
or deltaLink
here as per where you are in the sync process.RRuleSet
.occurrences
(type = occurrence
) received from the MSGraph api call.exception
s (type = exception
) received from the MSGraph api call.EXDates
based on the date diff generated earlier.Use the exceptions (i.e: one-off edited events in a recurring series) to create events as per your calendar requirements. Note: since one-off exceptions are not sent with type = occurrence
, the event instance diff generated to calculate the EXDates is accurate.
Additional notes:
For correct daylight saving adjustments, use the windows-iana npm to translate between MS timezones and IANA timezones (if required), and ensure both the RRule and EXDates added to your RRuleSet make use of the tzid
property.
If a recurring event is cancelled in Outlook calendar, all we get in the callback is the recurring event's id. Ensure you link your local event representation of one-off
events with the recurring event's id so you can clean-up event instances / mark events as cancelled.
Things the MS API could do better:
Upvotes: 3