我想使用 Office 365 API 将新事件添加到自定义日历(名为“Calendar XY”)。我不知道为什么,但所有事件总是被添加到默认日历中(名为“日历”)。
_client.Me.Calendars[myCalendar.Id].Events.AddEventAsync(newEvent);
使用Fiddler进行检查时,我已经注意到,即使@odata.context
正确(ID为“日历XY”),@odata.editLink
仍指向默认日历ID。
这里是完整的背景,但我没有看到任何有趣的东西:
const string ExchangeResourceId = "https://outlook.office365.com";
const string ExchangeServiceRoot = "https://outlook.office365.com/ews/odata";
var _authenticator = new Authenticator();
var authInfo = await _authenticator.AuthenticateAsync(ExchangeResourceId);
var _client = new ExchangeClient(new Uri(ExchangeServiceRoot), authInfo.GetAccessToken);
var myCalendar = await (
from calendar in _client.Me.Calendars
where calendar.Name == "Calendar XY"
select calendar
)
.ExecuteSingleAsync();
var newEvent = new Event
{
Start = dayData.DateTimeFrom,
End = dayData.DateTimeTo,
Location = new Location { DisplayName = dayData.Location },
Subject = dayData.Subject,
Importance = Importance.Low,
ResponseRequested = false,
ShowAs = FreeBusyStatus.Free,
};
await _client.Me.Calendars[myCalendar.Id].Events.AddEventAsync(newEvent);
答案 0 :(得分:1)
首先,感谢您使用新的Office 365 API!在深入研究之后,看起来好像这是服务层的错误。我打开了跟踪问题。我们需要深入研究这一点并对我们进行一些代码更改。我们将解决这个问题,但是我没有关于它何时在服务中修复的ETA。感谢您的反馈!
大卫洛杉矶 高级项目经理 - 交流