CalendarView and DeltaToken in different time range with Microsoft Graph API - microsoft-graph-api

From the Graph Documentation:
if you want a calendarView for a specific time range you use the query
GET https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2017-01-01T19:00:00.0000000&endDateTime=2017-01-07T19:00:00.0000000
if you want a delta token to get the changes in a calendarView you use the query
GET https://graph.microsoft.com/v1.0/me/calendarview/delta?startdatetime={start_datetime}&enddatetime={end_datetime}
My problem is taht I need to get all the events from a specific date at the beginning of my program, but after that I'm interesting to track changes of events from another date.
So I'm wondering if is it possible to get a calendarView for a specific time range and a delta token for another time range in a single query?

It is not possible to do this in a single query. Please issue two separate queries.
Thanks!
Sri

Related

Different serach results for Calendarview and Events

I was trying following two queries and only 1st query give correct events results according the given date range.
Is there any reason for giving all events when i use me/events in 2nd request ?
1st
https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2020-07-02T10:20:52.032Z&enddatetime=2020-07-09T10:20:52.032Z
2nd
https://graph.microsoft.com/v1.0/me/events?startdatetime=2020-07-02T10:20:52.032Z&enddatetime=2020-07-09T10:20:52.032Z
Response of 2nd query
The startDateTime and endDateTime query parameters aren't used by the /me/events endpoint. Those are specific to /me/calendarview.
Calendar view requires a "time window", because it expands recurring events and returns an entry for each occurrence that happens between those times. If it wasn't bounded, this could result in infinite occurrences, since you can create recurring events with no end date :).
The /me/events endpoint doesn't expand recurring events, so it just returns the series masters and single-occurrences on the calendar.

How to retreive delta calendarView from ms graph expanded with extension?

is there any smart way to get delta events from ms graph with extension?
Standard delta query is:
https://graph.microsoft.com/v1.0/me/calendarView/delta?startdatetime=2018-12-16T19:40:53&enddatetime=2020-12-16T19:40:53
Standard query for events with extension is:
https://graph.microsoft.com/v1.0/me/events/?$expand=extensions(%24filter%3did+eq+%27Microsoft.OutlookServices.OpenTypeExtension.Com.XXX.YYY%27)
and I couldn't find in documentation way to merge it and query for delta with "$expand=extensions".
Simpliest way, which comes to my mind is to ask api for delta and then ask one by one for expanded view object, but it's causes lots ot queries :/

How to find recurrence exceptions through Microsoft Outlook Calendar Graph API

I'm currently using the Microsoft Graph API to sync calendar events to my local application. On my end, I don't care to save each individual occurrence in a series, but prefer instead to just save the series master and then extrapolate out the instances of the series myself. For this reason, I am using the /me/events call rather than the /me/calendarView call.
My problem is when editing a single occurrence in a series. After editing the single occurrence, I make the /me/events call and I can see the newly added "Exception" type -- which is great. However, I don't see how to relate that new event back to which occurrence was changed to cause the exception.
For example, if I have a weekly meeting on Monday at noon, and I change today's meeting from noon to 2:00, it's pretty easy to tell that today's meeting is the one that changed. But if I change today's meeting to Friday, how can I tell that it was today's meeting that changed and not next week's? Keep in mind that I am only storing the master, and not every single calendarView occurrence.
Another example is if I delete an occurrence. In this case, the /me/calendarView call will simply not return that occurrence anymore. No exception type is generated. And the series master returned from the /me/events call doesn't change at all to indicate that a date is missing.
The format that I'm used to is something like the iCal/vCal format, where there is a start date, end date, and then a list of exception dates. Using that format, I can easily tell from the series master which dates to skip, without needing to "render" the entire occurrence and skip the exceptions. And if an occurrence is deleted, it is added to the EXDATE list and then it is never considered on rendering. Does the Microsoft Graph API not have an easy way to see these changed/deleted occurrences?
I was having a similar issue, but I think I've now realized that Microsoft does not allow recurring events to move later than the next instance, or earlier than the preceding one (at least while using Outlook calendar in the browser). So you can always assume that the 3rd event is 3rd in the series, the 4th is 4th, etc.
So as long as you know the series number, you can locate it by getting all of the instances with /me/events/[event_id]/instances?startDateTime=[start_date_time]&endDateTime=[end_date_time].
The error in Outlook Calendar when I do this isn't very clear, so maybe something else is up, but I am able to move the exception events otherwise. Unfortunately, I'm not sure if there's a definite way to know what end_date_time to use, as events can be moved indefinitely later.
Based on the response object from the event marked as an exception, you can use the seriesMasterId to relate the exception to its parent recurrence.

Microsoft Graph filter vs $filter

I am testing filtering using Microsoft Graph Explorer. I noticed odd behavior that I cannot figure out.
Using endpoint https://graph.microsoft.com/v1.0/me/events?filter=start/dateTime%20ge%20%272018-04-01%27 I get properly filtered data back.
However, using documented $ prefix, https://graph.microsoft.com/v1.0/me/events?$filter=start/dateTime%20ge%20%272018-04-01%27, I get nothing. There is no error, just no data coming back.
How do I query the data using the $filter?
You're not actually getting the results you think you are. When Microsoft Graph sees a query parameter it doesn't expect, it simply ignores it.
When you call /events?filter=start/dateTime ge '2018-04-01' it is simply ignoring the unknown filter parameter and returning you an unfiltered result.
When you call /events?filter=start/dateTime ge '2018-04-01', it is filtering out anything prior to April 1, 2018. If there are no events with a start after this date, you will get an empty array as a result.
I assume you're using the default dataset included with Graph Explorer? The default Graph Explorer data set's most recent event is 2017-11-16T08:00:00.0000000.
The reason you see results from the /calendarView endpoint but not the /events endpoint is that /events only returns single instance meetings and series masters while /celandarView shows everything within a date range. In order to avoid having to maintain a dataset with updated events, the demo data relies on a handful of recurring event entries.
Since events does not return individual occurrences of a meeting, you don't see any results from your query.
If you try this query, you'll see actual results:
https://graph.microsoft.com/v1.0/me/events?$filter=start/dateTime ge '2017-04-01'

Microsoft graph API: getting 5 next instances of recurring meeting

is there a way to query for next 5 instances of given series? I am querying using time-frame:
1. ask for all the meetings for next 7 days for all user events
2. Go over each event fetched and check if event has masterSerieId
3. Return matching instances.
This feels (and is) a bit painful.
Can i request next X instances of master series right away? I can't just simply or 'simply' get them based on recurrence rule, as some might have expired.
I could image I could ask for a year ahead and pass as a query parameter masterSeriesId and limit output with $top. Is that right approach?
Based on this document, you could call /events//instances – given a start time, returns all instances in the requested time frame of the meeting specified by the provided series master ID

Resources