本文介绍了Microsoft Graph SDK .NET获取范围内的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下代码获取所有事件在一定范围内

I tried to get all the events in a certain range using the following code

DateTime dateStart = DateTime.Parse("2018-07-20T11:00:00"), dateEnd = dateStart.AddDays(1);

List<QueryOption> options = new List<QueryOption>()
{
    new QueryOption("startDateTime", dateStart.ToUniversalTime().ToString()),
    new QueryOption("endDateTime", dateEnd.ToUniversalTime().ToString())
};

var eventsInRange = await graphClient.Me.Calendar.Events.Request(options).GetAsync();

但是它返回所有历史记录中的事件,而不仅仅是范围内的事件.有办法解决吗?

But it returns the events in all history, not only in range. Is there a way to solve this?

推荐答案

您正在呼叫 /events 终结点,使用 /calendarView 参数.您要使用CalendarView类:

var eventsInRange = await graphClient.Me
    .Calendar
    .CalendarView
    .Request(options)
    .GetAsync();

这篇关于Microsoft Graph SDK .NET获取范围内的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 19:30