【问题标题】:Calendar events $filter query on start/timeZone in Microsoft Graph APIMicrosoft Graph API 中开始/时区的日历事件 $filter 查询
【发布时间】:2019-06-08 01:28:43
【问题描述】:

我想通过提供 OData v4.0 $filter 作为查询参数来对 https://graph.microsoft.com/v1.0/me/calendars/<calendar>/events 端点应用过滤器,但将 eq 应用于 start/timeZone 会导致错误:

$filtersubject eq 'My Subject' and start/dateTime eq '1970-01-01T00:00:00.0000000' and end/dateTime eq '1970-01-01T00:01:00.0000000' and start/timeZone eq 'UTC' and end/timeZone eq 'UTC' 我回来了:

{
  "error": {
    "code": "InvalidDateTime",
    "message": "The value 'UTC' of parameter 'DateTime' is invalid.",
    "innerError": {
      "request-id": "68f797e2-5059-4a8a-8fc6-0063e31d6498",
      "date": "2019-06-07T13:46:54"
    }
  }
}

文档引用了Prefer: outlook.timezone 标头,但仅表明它适用于响应,并没有说明解释请求:

对于所有返回事件的 GET 操作,您可以使用 Prefer: outlook.timezone 标头指定事件开始的时区 以及响应中的结束时间。

如何过滤 (dateTime, timeZone) 组合?如果我不必知道事件的时区,而是可以基于 UTC 进行查询,那将是最好的,但我也不知道该怎么做。

谢谢!

【问题讨论】:

    标签: microsoft-graph-api microsoft-graph-calendar


    【解决方案1】:

    你不能过滤timeZone,你也不应该过滤。所有 DateTime 值都以 UTC 格式存储。仅当您包含 Prefer: outlook.timezone 时,它们才会转换为本地时区

    你应该能够简单地使用

    subject eq '{subject}' and start/dateTime eq '{date}T{time}' and end/dateTime eq '{date}T{time}'
    

    【讨论】:

    • 太棒了!我没有看到它记录了该请求将以 UTC 解释。是吗,还是我可以提交更新文档的请求?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多