Microsoft Graph:无法更新事件的开始或结束日期 [英] Microsoft Graph: Unable to update Start or End Date of an event
问题描述
我正在使用
代码:
- 如果我取消注释行
Start = {DateTime ="2020-08-20T08:30:00.0000000&",TimeZone ="UTC",则会发生上述错误.}
. -
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:
- The above error occurs if I uncomment the line
Start = { DateTime = "2020-08-20T08:30:00.0000000", TimeZone = "UTC" }
below. - 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 lineStart =....
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屋!