Microsoft Graph:无法更新事件的开始或结束日期
Microsoft Graph: Unable to update Start or End Date of an event
我正在使用 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 类型)我收到如下所示的错误:
问题: 错误的原因可能是什么,我们该如何解决?请注意,该活动的有效本地开始日期和结束日期分别为 8/21/2020 11:00AM
和 8/21/2020 11:30AM
。实际上,在调试模式下,VS2019
显示:Start.get returns null
错误截图:
代码:
- 如果我取消注释下面的
Start = { DateTime = "2020-08-20T08:30:00.0000000", TimeZone = "UTC" }
行,就会出现上述错误。
authProvider
和 "{id}"
变量的值与错误无关,因为具有实际值的代码在没有代码行 Start =....
的情况下工作正常。
...
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);
你需要这样的东西,因为 属性
中使用了对象类型
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" }
};
您需要按照以下格式添加日期。希望它能解决您的问题。
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 = "GMT Standard Time" }
};
我正在使用 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 类型)我收到如下所示的错误:
问题: 错误的原因可能是什么,我们该如何解决?请注意,该活动的有效本地开始日期和结束日期分别为 8/21/2020 11:00AM
和 8/21/2020 11:30AM
。实际上,在调试模式下,VS2019
显示:Start.get returns null
错误截图:
代码:
- 如果我取消注释下面的
Start = { DateTime = "2020-08-20T08:30:00.0000000", TimeZone = "UTC" }
行,就会出现上述错误。 authProvider
和"{id}"
变量的值与错误无关,因为具有实际值的代码在没有代码行Start =....
的情况下工作正常。
...
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);
你需要这样的东西,因为 属性
中使用了对象类型 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" }
};
您需要按照以下格式添加日期。希望它能解决您的问题。
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 = "GMT Standard Time" }
};