突破性改变?在 Office 365/Outlook 的日历视图 api 中使用 odata.track-changes 时未收到 odata.nextLink?

Breaking change? Not receiving odata.nextLink when using odata.track-changes in Office 365 / Outlook's calendarview api?

我不确定这是什么时候开始发生的(我相信是最近)。如果您依赖此处记录的步骤,这是一个 重大更改

https://msdn.microsoft.com/en-us/office/office365/howto/sync-calendar-view

问题是 Office 365 和 Outlook.com calendarview api 似乎不再 return @odata.nextLink 如果有更多数据要获取您在请求中为 "Prefer" header 指定 "odata.track-changes"。

这是一个重现问题的 CURL 请求...请务必将请求验证为在指定时间范围内至少有 50 个事件的用户(以触发分页)。

curl -H "Authorization: Bearer <OMITTED>" -H "Accept: application/json; odata.metadata=none" -H "Prefer: odata.track-changes" "https://outlook.office.com/api/v2.0/me/calendarview?startdatetime=2016-06-16T00:00:00Z&enddatetime=2017-06-23T00:00:00Z"

当我发出此请求时,生成的响应有 10 个条目(即使至少有 50 个事件)并且响应没有 @odata.nextLink。但是它确实有一个@odata.deltaLink。

还有其他人遇到这个问题吗?

据我所知,它一直都是这样工作的。初始同步 returns 一个 deltaLink 而不是一个 nextLink。您必须特别对待该初始同步请求,然后继续使用 deltaToken.

发出下一个请求
  1. Initial sync request: The very first sync request sets up the sync state.
  2. Initial sync response:
    • Check for "Preference-Applied: odata.track-changes" in the response header to confirm a successful sync attempt and the resource supports synchronization.
    • If the sync attempt was successful, the initial response always contains an @odata.deltaLink with a deltaToken value. If the response contains any data, save the deltaToken value for the second request.
    • If the initial response wasn't successful, or doesn't return any data indicating there are no events in the specified calendar view, this round of sync ends.
  3. Subsequent sync request: Use the deltaToken or skipToken value from the previous request to issue the next request. See the second and third sync requests as examples.
  4. Subsequent sync response:
    • If the response returns any data, and, there is more data to sync in that time range, the response would include an @odata.nextLink and a skipToken value. Save the skipToken for the next sync request.
    • Go back to step 3, follow the nextLink, if any, apply the corresponding skipToken value in the next sync request, and follow any subsequent nextLink, until you have synchronized all the data in the time range for that calendar.
  5. Final sync response: When all events in the calendar view are synchronized, the final response in this round would include an @odata.deltaLink and a deltaToken again. Save the deltaToken value for the next round of synchronization.