Get events without start and end date

时间:2019-04-08 13:47:52

标签: microsoft-graph microsoft-graph-calendar

In the Microsoft Graph Calendar API I can get all events with the request url:

/me/calendarView/delta?startDateTime={start_datetime}&endDateTime={end_datetime}

But I have to specify a start and end date. Is there a way to just get all events without specifying the dates?

Just leaving the dates out of the request gives me an error that it is missing those parameters.

1 个答案:

答案 0 :(得分:1)

/calendarView端点旨在为您提供给定日期范围内日历的渲染视图。如果没有日期范围,API将不得不呈现日历中的每个事件,这可能要追溯到几十年前。这样做的计算成本可能过高,更不用说它将对大规模性能产生负面影响。

如果只需要原始基础event对象,则可以使用/events端点。这将使您分页显示包含该日历中每个事件的结果。您将需要进行一些后期处理,以基于主事件(例如,带有"eventType": "seriesMaster"的事件)呈现单个实例以重复事件。

通常,我建议使用/calendarView,因为它可以为您处理系列实例。您可以通过传递足够大的窗口来有效地模仿检索“所有内容”,尽管这会对性能造成影响。

为说明起见,在Graph Explorer中调用以下URI将返回整整十年(2009-2019)的事件:

https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2009-01-01&enddatetime=2019-12-31

值得注意的是,这花费了6,436毫秒来返回结果,并且数据仅包含少量事件。当我对 my 日历运行相同的查询时,它花费了13883毫秒。因此,仅从性能角度来看,我建议您一次不建议一次查询超过12个月(即startdatetime=2018-01-01&enddatetime=2018-12-31花费了2795ms)。

相关问题