首页 > 解决方案 > 用于获取日历事件的 MSGraph Api

问题描述

我正在尝试使用 Microsoft graph api 获取日历事件。(GET /me/calendar/calendarView?startDateTime={start_datetime}&endDateTime={end_datetime})我正在获取下一组事件的响应 JSON(其中包含前 10 个事件)url . 我使用改造来获得这些事件。

第一个请求的 URL

https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2021-03-17T00:00:00.788Z&endDateTime=2021-03-19T23:59:00.788Z

这是下一个事件的 网址 https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2021-03-18T00%3a00%3a00.425Z&endDateTime=2021-03-21T23%3a59% 3a00.426Z&%24top=10&%24skip=20

现在的问题是如何按顺序调用改造 api,每个响应 json 都有下一个请求 url。我必须使用它并发送新的改造请求。

标签: androidmicrosoft-graph-apiretrofit2

解决方案


您可以简单地使用以下 HTTP 调用根据开始日期时间顺序获取事件。

https://graph.microsoft.com/v1.0/me/calendarView?startDateTime=2020-01-01T19:00:00-08:00&endDateTime=2020-12-12T19:00:00-08:00&$select=id, subject, start, end&$top=100&$orderby=start/dateTime

这里 $top 可以改变每页的记录数,它的值范围是 1 到 999,如果你的记录超过 999,你需要使用 nextLink 来获取下一组记录,这将是有序的。

我使用 $orderBy 根据开始日期时间顺序获取记录。


推荐阅读