禁止Google Calendar Api插入事件[403]

时间:2018-09-16 00:56:34

标签: c# google-calendar-api

我有.dotnet核心Web应用程序。我正在尝试通过Google Calendar Api添加事件,但出现错误。错误

  

禁止Google.Apis.Requests.RequestError [403]错误[     消息[禁止访问]位置[-]原因[禁止访问域[全局]]

我的代码是

Event myEvent = new Event
                    {
                        Summary = "Appointment",
                        Location = "Dhaka",
                        Start = new EventDateTime()
                        {
                            DateTime = new DateTime(2018, 9, 17, 10, 0, 0),
                            TimeZone = "Asia/Dhaka"
                        },
                        End = new EventDateTime()
                        {
                            DateTime = new DateTime(2018, 9, 17, 10, 30, 0),
                            TimeZone = "Asia/Dhaka"
                        },
                        Recurrence = new String[] {
                                "RRULE:FREQ=WEEKLY;BYDAY=MO"
                            },
                        Attendees = new List<EventAttendee>()
                        {
                          new EventAttendee() { Email = "alimcu08@gmail.com" }
                        }
                    };

                    var newEventRequest = calendarService.Events.Insert(myEvent, calendarId);

                    var eventResult = newEventRequest.Execute();

执行运行时出现错误。通过使用相同的日历服务,我已经成功获取了日历和事件列表,但是无法添加事件。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

Google提供了3个具有不同ID的日历。我从他们那里提供了一个ID。这就是为什么未添加事件。当我用“ primary”替换id时,它工作正常。