0

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/user@user.com/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?

Community
  • 1
  • 1
user263367
  • 15
  • 1
  • 5

1 Answers1

3

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
Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • Thanks @Jason for the quick response, unfortunately I still get the same error message :( this is the query I used `/events?$top=100&$select=BodyPreview&$filter=Start/DateTime ge 2016-02-10T22:00:00Z` – user263367 Feb 08 '16 at 20:33
  • I needed to put the DateTime within quotes to make it work `$filter=Start/DateTime eq \'2015-09-25T09:00:00\'` Now it works, thanks again @Jason! – user263367 Feb 08 '16 at 21:02
  • Gotcha. Note that you can also use `CalendarView` to get all events in a specified window of time, which has the added benefit of expanding recurring events for you (if that fits what you're trying to achieve, of course!) – Jason Johnston Feb 08 '16 at 21:07
  • thank you Jason. I don't believe this was well documented in API. – user3658423 May 17 '16 at 05:43
  • Thx user263367! It was the two backslashes I missed (\'2015-09-25T09:00:00\'). Spent several hours before I found this post.. – Paintoshi Jan 24 '17 at 14:55