首页 > 解决方案 > 使用 C# 中的 API 设置 Google 日历事件的颜色

问题描述

我对使用 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-coregoogle-calendar-api

解决方案


看起来它可能是一个错误CalendarList 背景颜色更改不起作用(.NET)

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

我已向 Google 发送了一封电子邮件,但我与该团队没有直接联系,我需要一段时间才能听到任何消息。


推荐阅读