Microsoft Graph:无法更新事件的开始或结束日期 [英] Microsoft Graph: Unable to update Start or End Date of an event

查看:54
本文介绍了Microsoft Graph:无法更新事件的开始或结束日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

代码:

  1. 如果我取消注释行 Start = {DateTime ="2020-08-20T08:30:00.0000000&",TimeZone ="UTC",则会发生上述错误.} .
  2. authProvider "{id}" 变量的值与错误无关,因为带有真实值的代码在没有行代码的开始= .... .

...

  GraphServiceClient graphClient = new GraphServiceClient(authProvider);var @event =新事件{主题=测试主题",正文=新的ItemBody {内容=测试正文内容"}//开始= {DateTime ="2020-08-20T08:30:00.0000000&",TimeZone ="UTC"}};等待graphClient.Me.Events ["{id}"].要求().UpdateAsync(@event); 

解决方案

由于属性中使用了对象类型,因此您需要这样的东西

  var @event =新事件{主题=测试主题",正文=新的ItemBody {内容=测试正文内容";},开始=新的DateTimeTimeZone {DateTime ="2020-08-20T08:30:00.0000000&",TimeZone ="UTC"}}; 

I'm using Microsoft Graph .NET SDK to update outlook events. Following code successfully updates the Subject, and Body attributes of an event. But when I try to update the Start and/or End dates of the the event (that are of the dateTimeTimeZone type) I get the error shown below:

Question: What may be the cause of the error, and how can we resolve it? Please note that the event has valid local Start and End dates as 8/21/2020 11:00AM and 8/21/2020 11:30AM respectively. Actually, in the debug mode, VS2019 is showing: Start.get returns null

Screenshot of the error:

Code:

  1. The above error occurs if I uncomment the line Start = { DateTime = "2020-08-20T08:30:00.0000000", TimeZone = "UTC" } below.
  2. The values of authProvider and "{id}" varibles are not that relevant to the error as the code with the real values works fine without the line Start =.... of the code.

...

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var @event = new Event
{
    Subject = "Test subject",
    Body= new ItemBody { Content = "Test body content"}
    //Start = { DateTime = "2020-08-20T08:30:00.0000000", TimeZone = "UTC" }
};

await graphClient.Me.Events["{id}"]
    .Request()
    .UpdateAsync(@event);

解决方案

You need something like this instead because of the object type being used in the property

            var @event = new Event
        {
            Subject = "Test subject",
            Body = new ItemBody { Content = "Test body content" },
            Start = new DateTimeTimeZone {  DateTime = "2020-08-20T08:30:00.0000000", TimeZone = "UTC" } 
        };

这篇关于Microsoft Graph:无法更新事件的开始或结束日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆