有没有一种方法可以在 Office 365 API 中通过一个电话从所有用户日历(默认和其他日历)中获取事件。

Is there a way to get events from all users calendars (default and others) in one call in office 365 API.

在 office 365 API 中,我没有找到任何一项服务 returns 一次呼叫中来自用户日历的所有事件。 如果用户有 3 个日历,则需要通过传递日历 Id 进行三个调用。

首先需要通过调用

获取日历ID
https://outlook.office.com/api/v1.0/me/calendars

然后对于每个Calendar Id,需要通过调用

获取事件
GET https://outlook.office.com/api/{version}/me/calendars/{calendar_id}/calendarview?startDateTime={start_datetime}&endDateTime={end_datetime}

如果有任何单个调用,则将减少往返。

感谢您的帮助。

不,没有一次调用可以获取所有日历的 "merged" 视图。这是一个有趣的想法,我认为你应该 post 它在 UserVoice

确实我们不能一次命中多个日历,但是我们可以使用并行的foreach来同时调用以获得更快的响应。

Task[] CalendarListEvents = new Task[CalendarList.Count];
Parallel.ForEach(CalendarList, (Calendar) =>
{ 
    tasksToFetchDailyEvents[index] = Task.Factory.StartNew(() =>
    {               
              // Code to fetch Events and add to list
    });

});
Task.WaitAll(CalendarListEvents);