Microsoft Graph API calendarView 是否仅限于一个月?如何获取所有事件? [英] Is Microsoft Graph API calendarView limited to a single month? How to get all events?

查看:14
本文介绍了Microsoft Graph API calendarView 是否仅限于一个月?如何获取所有事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft Graph API calendarView 是否仅限于一个月?如何获取所有事件?是否有一些隐式分页?

Is Microsoft Graph API calendarView limited to a single month? How can I get all events? Is there some implicit pagination?

我首先检查 2017-01-012018-12-30<之间事件的 JSON 输出/strong>:

I'm first checking the JSON output of events between 2017-01-01 and 2018-12-30:

https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2017-01-01T00:00:00.0000000&endDateTime=2018-12-30T00:00:00.0000000

并列出日期

jq '.value[] .start .dateTime'

"2017-11-22T13:30:00.0000000"
"2017-11-23T14:00:00.0000000"
"2017-11-24T14:00:00.0000000"
"2017-11-27T10:00:00.0000000"
"2017-11-27T10:00:00.0000000"
"2017-11-27T11:00:00.0000000"
"2017-11-27T14:30:00.0000000"
"2017-11-28T09:00:00.0000000"
"2017-11-29T09:00:00.0000000"
"2017-11-29T14:00:00.0000000"

例如,2017 年第 12 个月没有日历活动!但我有!

No calendar events from 12th month of 2017 for example! But I have them!

然后通过缩小 2017-12-012018-12-30 之间的日期范围的左端来执行类似的调用,现在我得到:

And then do a similar call for by narrowing the left end of dates range between 2017-12-01 and 2018-12-30, and now I get:

"2017-12-01T12:30:00.0000000"
"2017-12-01T14:00:00.0000000"
"2017-12-04T08:30:00.0000000"
"2017-12-04T12:00:00.0000000"
"2017-12-06T09:00:00.0000000"
"2017-12-06T10:00:00.0000000"
"2017-12-07T13:00:00.0000000"
"2017-12-13T09:00:00.0000000"
"2017-12-13T09:00:00.0000000"
"2017-12-13T13:00:00.0000000"

我对 列表感到困惑calendarView列出事件 文档.

我如何才能在我的日历中获取所有事件,我可以清楚地看到 2017 年 11 月和 12 月以及 2018 年 1 月和 2 月存在的事件?

How can I get all of the events in my calendar, the ones that I can clearly see to exist in November and December of 2017, as well as in January, and February of 2018?

我是否必须在一年中的每个月重复调用此 API?(我希望我可以打一个电话来获取一年或两年内的所有事件,之后我可以过滤、处理等)

Do I have to call this API repeatedly for every month in a year? (I hope there's a single call I can make to get all the events in a year, or two years, after which I can filter, process, etc.)

推荐答案

list events和list calendarView的区别

当您列出事件 (GET/me/events) 时,您会在日历中获得一个非扩展项目列表.这意味着如果您有重复事件,您只会在结果中获得系列大师.您可以阅读重复模式并扩展事件.

When you list events (GET /me/events), you get a non-expanded list of items in the calendar. What that means is that if you have recurring events, you would only get the series master in your results. It would be up to you to read the recurrence pattern and expand the event.

当您列出日历视图 (GET/me/calendarview?...) 时,您会得到一个扩展 项目列表.这意味着服务器会扩展任何重复发生的事件并构建日历的视图".因此,在这种情况下,如果您有一个重复事件,而不是获取系列主控,您将获得系列的一次或多次出现(取决于它在您的视图窗口中重复的次数).由于这种扩展工作,您必须提供开始和结束时间以对调用设置某种界限.

When you list a calendar view (GET /me/calendarview?...), you get an expanded list of items. That means the server does the work to expand any recurring events and build a "view" of your calendar. So in this case if you have a recurring event, instead of getting the series master, you would get one or more occurrences of the series (depending on how many times it repeats in your view window). Because of this expansion work, you must provide a start and end time to put some sort of bounds on the call.

查看它的另一种方式是日历视图更像是您在 Outlook 中查看日历时所看到的.

Another way of looking at it is the calendar view is more like what you're used to seeing when you view your calendar in Outlook.

那么我的所有活动在哪里?

我不知道日历视图的窗口大小有任何具体限制.(不是说没有,我只是不知道).更可能的解释是您没有看到所有预期的事件,因为所有返回集合的 API 请求都具有内置分页.默认情况下,您在响应中限制为 10 个项目.您还应该在响应中看到 @odata.nextLink,这是您可以用来请求下一页结果的 URL(同样,10 是默认页面大小).您可以使用 $top 参数增加页面大小,最大为 1000 (IIRC).

I'm not aware of any specific limitation on the size of the window for a calendar view. (Not saying there isn't one, I'm just not aware of it). The more likely explanation is that you're not seeing all the events you expect because all API requests that return collections do have built-in paging. By default, you're limited to 10 items in the response. You should also see in your response an @odata.nextLink, which is the URL you can use to request the next page of results (again, 10 being the default page size). You can increase your page size by using the $top parameter, up to a maximum of 1000 (IIRC).

GET /me/calendar/calendarView?startDateTime=2017-01-01T00:00:00.0000000
    &endDateTime=2018-12-30T00:00:00.0000000&$top=1000

这篇关于Microsoft Graph API calendarView 是否仅限于一个月?如何获取所有事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆