Dmitriy Konyayev
Dmitriy Konyayev

Reputation: 67

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?

Upvotes: 2

Views: 1036

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

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'

Upvotes: 3

Related Questions