Odata v.4 $过滤Office 365 REST API中的DateTime日历事件

时间:2016-02-08 18:52:39

标签: rest odata uri ms-office office365

我尝试使用以下查询从Office 365 REST API获取和过滤日历事件:

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

所以我想要100个结果,只有BodyPreview作为所有大于2016-02-10 22:00:00的事件的返回值。

我收到的错误信息就是这个:

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\'.'

没有过滤器选项的查询可以完美地运行。那么如何让我的查询代表一个' Microsoft.OutlookServices.DateTimeTimeZone'类型?

我看过这篇文章: Odata $filter for the date in the Office 365 REST API

但我看不出我的查询和帖子中的查询之间的区别。

https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar上的所有示例都未在示例中提及此类型的DateTimeTimeZone查询。

我也试过这种查询格式:

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

也没有运气。 有什么想法吗?

1 个答案:

答案 0 :(得分:3)

StartEnd changed in the beta and v2 endpoints的类型。它现在是一个复杂的类型,因此您需要稍微更改一下过滤器:

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