通过API添加的事件在Google日历中不可见

时间:2016-02-20 20:37:25

标签: google-api google-calendar-api google-api-dotnet-client

我们正在通过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

直接检索事件
            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" 

1 个答案:

答案 0 :(得分:0)

感谢@luc,

此处的问题是,用户确实在其日历设置中设置了以下设置= &#39;否,仅显示我已回复的邀请&#39;

在我的示例中,添加了EventAttendee,但他们的ResponseStatus是&#39; actionNeeded&#39; - 因此尽管所有者是用户,但在日历中却看不到它。

如果在我的代码中,我将EventAttendee的ResponseStatus设置为“已接受”&#39;然后它在用户日历中变得可见。正确的代码必须是:

        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();