通过API的Google日历提醒无效

时间:2015-03-12 10:42:03

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

我正在尝试通过2个自定义提醒向Google日历Insert发送新活动,但这些活动尚未设置。

似乎提醒7 + 9分钟是通过代码设置的(检查输出)。

但是在日历Web GUI中,事件会显示默认提醒设置。

            // Insert new
        var r1 = new EventReminder { Method = "popup", Minutes = 7 };
        var r2 = new EventReminder { Method = "popup", Minutes = 9 };
        var erd = new Event.RemindersData {UseDefault = false, Overrides = new [] {r1 , r2}};

        var ev = new Event
        {
            Created = DateTime.Now,
            Creator = new Event.CreatorData {DisplayName = "Foobar"},
            Description = "Foo",
            Summary = "Bar",
            Location = "Baz",
            Reminders = erd,
            Start = new EventDateTime {DateTime = DateTime.Now.AddHours(1)},
            End = new EventDateTime {DateTime = DateTime.Now.AddHours(2)}
        };

        try
        {
            var eventInsert = service.Events.Insert(ev, "***************'");
            var execResult = eventInsert.Execute();
            Console.WriteLine(execResult.Status);
            Console.WriteLine(execResult.Id);

            foreach (var r in execResult.Reminders.Overrides)
            {
                Console.WriteLine(" mins: " + r.Minutes);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }

输出:

confirmed
7ktkgedd536f********
mins: 7
mins: 9

结果图片网址:

result

1 个答案:

答案 0 :(得分:0)

我终于有时间进一步调查此事。 @peleyal让我走上正轨,我使用的是服务帐户

切换到OAuth解决了这个问题。