Microsoft graph api 日历视图迁移

Microsoft graph api calendarview migration

我在下面使用 url 来调用 ms 图表 api。现在我改为使用 nuget Microsoft.Graph (GraphServiceClient)。在 ms graph api 资源管理器中,调用按预期工作,但与 nuget 无关。有什么想法吗?

我现在尝试了一些变体,但无法得到相同的答案。
要求:

https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/calendar/calendarView?startDateTime=2021-08-19T09:22:00.6654083Z&endDateTime=2021-08-30T09:22:00.6654083Z&showAs=free&$select=showAs,start,end&$top=1000

我的代码尝试无效

 QueryOption startDateTime = new QueryOption("startDateTime", startDate.ToString("o"));
            QueryOption endDateTime = new QueryOption("endDateTime", endDate.ToString("o"));
            List<Option> options = new List<Option>();
            options.Add(startDateTime);
            options.Add(endDateTime);

            var items= await _graphServiceClient
                                    .Users[profileName]
                                    .Calendar
                                    .CalendarView
                                    .Request(options)
                                    .GetAsync();

在 ms graph apiexplorer 中有一个“不错”的功能,对我来说可能是新功能。

当您 运行 查询正确答案时。在答案框中有一个“代码片段”tab/button,然后您会看到所需的代码。在 CSharp 中对我来说。

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var queryOptions = new List<QueryOption>()
{
    new QueryOption("startDateTime", "2021-08-19T09:22:00.6654083Z"),
    new QueryOption("endDateTime", "2021-08-30T09:22:00.6654083Z"),
    new QueryOption("showAs", "free")
};

var calendarView = await graphClient.Users[profileName].Calendar.CalendarView
    .Request( queryOptions )
    .Select("showAs,start,end")
    .Top(1000)
    .GetAsync();
 var queryOptions = new List<QueryOption>()
            {
                new QueryOption("startDateTime", from.ConvertDateTimeToUtc(timeZone.WinTimeZone).ConvertDateTimeToUtcIso8601String()),
                new QueryOption("endDateTime", to.ConvertDateTimeToUtc(timeZone.WinTimeZone).ConvertDateTimeToUtcIso8601String()),
            };

var calendarView = await graphClient.Users[profileName].Calendar.CalendarView
.Request(queryOptions)
.GetAsync();
.GetAsync();