使用C#中的API设置Google日历事件的颜色

问题描述 投票:0回答:1

我对使用C#的Google Calendar API有疑问。我想设置特定事件的颜色,但无论我添加到ColorId属性,它都不会影响我更新后的事件。

这是我的代码:

 Event data = CalendarService.Events.Get("primary", id).Execute();
 data.Description = _GetDescription(done, notes, uniqueLinkId);

 Colors colors = CalendarService.Colors.Get().Execute();
 if (colors != null && colors.Calendar != null)
 {
      var color = colors.Calendar.FirstOrDefault(x => x.Value.Background == "#16a765");
      if (!string.IsNullOrWhiteSpace(color.Key))
      {
                data.ColorId = color.Key;
      }
 }

 var request = CalendarService.Events.Update(data, "primary", id);
 request.SupportsAttachments = true;
 request.SendNotifications = false;

 request.Execute();

关于这不起作用的任何想法?

此致,安德烈亚斯

c# asp.net .net-core google-calendar-api
1个回答
0
投票

看起来它可能是一个bug CalendarList background color change is not working (.NET)

唯一的问题是我无法使用Google API exporer进行设置。这让我想知道这是否是他们在新的Google日历发布后删除的内容。

我已经向Google发送了一封电子邮件,但我没有直接联系该团队,在我听到任何消息之前还有一段时间。

© www.soinside.com 2019 - 2024. All rights reserved.