0
votes

I have .dotnet core web application. I'm trying to add event by Google Calendar Api but getting error. The error

Google.Apis.Requests.RequestError Forbidden [403] Errors [ Message[Forbidden] Location[ - ] Reason[forbidden] Domain[global] ]

My code is

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 = "[email protected]" }
                        }
                    };

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

                    var eventResult = newEventRequest.Execute();

It's getting error when execute run. By using same calendar service I had got calendar and event list successfully but can't adding event. Any one can help?

1
How are you authenticating? - Dan Wilson
Using ClientId, ClientSecrets and RefreshToken - Md. Abdul Alim
@DanWilson It's work for getting CalendarList and EventList but exception for Inserting - Md. Abdul Alim
What are the scopes you are setting? - MatthewG
@MatthewG Scopes are CalendarService.Scope.CalendarReadonly, CalendarService.Scope.Calendar - Md. Abdul Alim

1 Answers

0
votes

Google provided 3 calendars whose have different id. I provided one id from them. That's why event not added. When I replace id by 'primary' it's working fine.