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

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

问题描述

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

我首先检查 2017-01-01 2018-12-30 之间的事件的JSON输出:

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月开始没有日历活动!但是我有他们!

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

"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月? /p>

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

解决方案

列表事件与列表calendarView之间的区别

列出事件(GET /me/events)时,会在日历中获得未展开的项目列表.这意味着,如果您有重复发生的事件,则只能在结果中获得系列母版.阅读重复模式并扩展事件将取决于您.

列出日历视图(GET /me/calendarview?...)时,会得到扩展的列表.这意味着服务器将进行工作以扩展所有重复发生的事件并构建日历的视图".因此,在这种情况下,如果您有一个重复发生的事件,那么您将获得一个或多个该系列(取决于它在视图窗口中重复的次数),而不是获得该系列的母版.由于进行了这项扩展工作,因此您必须提供开始时间和结束时间,才能在通话中设置某种界限.

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

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

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

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

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

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

and list the dates

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"

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

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"

I'm confused by List calendarView and List events documentation.

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?

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.)

解决方案

Difference between list events and list calendarView

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.

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.

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.

So where's all my events?

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天全站免登陆