Search code examples
restodataurims-officeoffice365

Odata v.4 $filter for the DateTime Calendar Events in the Office 365 REST API


I am trying to get and filter Calendar events from the Office 365 REST API with the following query:

https://outlook.office.com/api/v2.0/users/[email protected]/calendars/AAAAAAAAAAA/events?$top=100&$select=BodyPreview&$filter=Start ge 2016-02-10T22:00:00Z

So I want 100 results with only the BodyPreview as return value for all Events greater than 2016-02-10 22:00:00.

The Error Message I receive is this one:

ERROR request returned 400
error:
code: 'RequestBroker-ParseUri',
message: 'A binary operator with incompatible types was detected. Found operand types \'Microsoft.OutlookServices.DateTimeTimeZone\' and \'Edm.DateTimeOffset\' for operator kind \'GreaterThanOrEqual\'.'

The query without the filter option works flawlessly. So how do I get my query to represent a 'Microsoft.OutlookServices.DateTimeTimeZone' type?

I had a look at this post: Odata $filter for the date in the Office 365 REST API

But I can not see the difference between my query and the one in the post.

And all examples on https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar do not mention this type of DateTimeTimeZone query in the examples.

I also tried this query format:

datetime'2016-01-10T22:00:00'

Also no luck. Any ideas?


Solution

  • The type for Start and End changed in the beta and v2 endpoints. It's now a complex type, so you need to change your filter a bit:

    $filter=Start/DateTime ge 2016-02-10T22:00:00Z