通过 API 添加的事件在 Google 日历中不可见
Event Added Through API not visible in Google Calendar
我们正在通过日历添加活动 API
Event ev = new Event();
ev.Summary = "ILINK TEST - IGNORE";
ev.Start = new EventDateTime();
ev.Start.DateTime = DateTime.Now.AddMonths(-3);
ev.End = new EventDateTime();
ev.End.DateTime = ev.Start.DateTime;
ev.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.Email = "example@example.com";
ev.Attendees.Add(ea);
Event evv = service.Events.Insert(ev, "example@example.com").Execute();
当我们尝试在用户日历中查看事件时,它是不可见的。但是我们可以直接通过 Id
检索 Event
EventsResource.GetRequest gr = new EventsResource.GetRequest(service, "example@example.com", "43ha9dpv15h5oj2jv853g4vljk");
gr.AlwaysIncludeEmail = true;
Event evv = gr.Execute();
当我们删除所有者的与会者条目时 "example@example.com" 事件在日历中可见
evv.Attendees.Remove(ea);
所以我们看到的是,当活动的所有者是参与者时,它在他们的 Google 日历中是不可见的。
我检查了 ACL 规则并且存在以下条目
ETag "\"00000000000000000000\""
Id "user:example.example.com"
Kind "calendar#aclRule"
Role "owner"
感谢@luc,
这里的问题是用户确实在他们的日历设置中有以下设置 = 'No, only show invitations to which I have responded'
在我的示例中,添加了 EventAttendee,但他们的 ResponseStatus 是 'actionNeeded' - 因此尽管所有者是用户,但它在日历中不可见。
如果在我的代码中,我将 EventAttendee 的 ResponseStatus 设置为 'accepted',那么它将在用户日历中可见。正确的代码需要是:
Event ev = new Event();
ev.Summary = "ILINK TEST - IGNORE";
ev.Start = new EventDateTime();
ev.Start.DateTime = DateTime.Now.AddMonths(-3);
ev.End = new EventDateTime();
ev.End.DateTime = ev.Start.DateTime;
ev.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.Email = "example@example.com";
ea.ResponseStatus = "accepted";
ev.Attendees.Add(ea);
Event evv = service.Events.Insert(ev, "example@example.com").Execute();
我们正在通过日历添加活动 API
Event ev = new Event();
ev.Summary = "ILINK TEST - IGNORE";
ev.Start = new EventDateTime();
ev.Start.DateTime = DateTime.Now.AddMonths(-3);
ev.End = new EventDateTime();
ev.End.DateTime = ev.Start.DateTime;
ev.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.Email = "example@example.com";
ev.Attendees.Add(ea);
Event evv = service.Events.Insert(ev, "example@example.com").Execute();
当我们尝试在用户日历中查看事件时,它是不可见的。但是我们可以直接通过 Id
检索 Event EventsResource.GetRequest gr = new EventsResource.GetRequest(service, "example@example.com", "43ha9dpv15h5oj2jv853g4vljk");
gr.AlwaysIncludeEmail = true;
Event evv = gr.Execute();
当我们删除所有者的与会者条目时 "example@example.com" 事件在日历中可见
evv.Attendees.Remove(ea);
所以我们看到的是,当活动的所有者是参与者时,它在他们的 Google 日历中是不可见的。
我检查了 ACL 规则并且存在以下条目
ETag "\"00000000000000000000\""
Id "user:example.example.com"
Kind "calendar#aclRule"
Role "owner"
感谢@luc,
这里的问题是用户确实在他们的日历设置中有以下设置 = 'No, only show invitations to which I have responded'
在我的示例中,添加了 EventAttendee,但他们的 ResponseStatus 是 'actionNeeded' - 因此尽管所有者是用户,但它在日历中不可见。
如果在我的代码中,我将 EventAttendee 的 ResponseStatus 设置为 'accepted',那么它将在用户日历中可见。正确的代码需要是:
Event ev = new Event();
ev.Summary = "ILINK TEST - IGNORE";
ev.Start = new EventDateTime();
ev.Start.DateTime = DateTime.Now.AddMonths(-3);
ev.End = new EventDateTime();
ev.End.DateTime = ev.Start.DateTime;
ev.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.Email = "example@example.com";
ea.ResponseStatus = "accepted";
ev.Attendees.Add(ea);
Event evv = service.Events.Insert(ev, "example@example.com").Execute();