rossbot rossbot - 3 months ago 44
C# Question

How to delete event in Google Calendar using API v3 .NET?

I have this method:

public static void DeleteEvent(CalendarService service, Event eventToDelete, string calendarId = "primary")
{
service.Events.Delete(calendarId, eventToDelete.Id);
}


but it's failing to delete any events from the calendar.

What's am I doing wrong?

Answer

What you need to do is Add an .Execute() at the End of the line to execute the delete command, then it will be like the following:

 service.Events.Delete(calendarId, eventToDelete.Id).Execute();

You can refer this article as well for more informations