【问题标题】:Odata v.4 $filter for the DateTime Calendar Events in the Office 365 REST APIOffice 365 REST API 中 DateTime 日历事件的 Odata v.4 $filter
【发布时间】:2016-02-08 18:52:39
【问题描述】:

我正在尝试使用以下查询从 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'

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

【问题讨论】:

    标签: rest odata uri ms-office office365


    【解决方案1】:

    StartEnd changed in the beta and v2 endpoints 的类型。它现在是一个复杂的类型,所以你需要稍微改变你的过滤器:

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

    【讨论】:

    • 感谢@Jason 的快速响应,不幸的是我仍然收到相同的错误消息:( 这是我使用的查询/events?$top=100&$select=BodyPreview&$filter=Start/DateTime ge 2016-02-10T22:00:00Z
    • 我需要将 DateTime 放在引号中以使其工作$filter=Start/DateTime eq \'2015-09-25T09:00:00\' 现在可以工作了,再次感谢@Jason!
    • 明白了。请注意,您还可以使用CalendarView 来获取指定时间窗口内的所有事件,这具有为您扩展重复事件的额外好处(当然,如果这符合您想要实现的目标!)
    • 谢谢杰森。我不相信这在 API 中有很好的记录。
    • 谢谢用户263367!这是我错过的两个反斜杠(\'2015-09-25T09:00:00\')。花了几个小时才找到这篇文章..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多