Error 404 when creating a calendar with Google Calendar Api v3 using c# .net

gdata, google-calendar-api, http-status-code-404

Solution

Okey, my bad:

You can't create a calendar with your own identifier, the purpose of CalendarListEntry.Insert() is to insert a created Calendar into the list of calendars

So to create a new calendar one has to:

Insert a new Calendar: https://developers.google.com/google-apps/calendar/v3/reference/calendars/insert

(DO NOT add id as paramater, this will be automatically created)

Insert the ID of the calendar created in step 1 and insert it into the calendarList: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert

Problem

I am trying to create a calendar using Google Calendar API v3 if it does not already exist. My implementation successfully retrieves all my calendars and events and can change calendars, but I am struggling with adding a new calendar. This is what I do in order to try to add a new calendar for the user: ``` ... var calendarService = new CalendarService(_authenticator); var calendarId = "com.somedomain.somename.1234"; // Some random ID try { calendarManager.GetCalendar(calendarId); // No calandar found } catch(GoogleCalandarServiceProxyException e){ // Ok, so far so good, calendar not found (that is correct) and I am here var someCalendar = new Google.Apis.Calendar.v3.Data.CalendarListEntry { Summary = "Some summary!", Description = "A calendar descr.", AccessRole = "writer", BackgroundColor = "#E7323C", Id = calendarId }; calendarService.CalendarList.Insert(someCalendar).Fetch(); // Fetch to execute } ``` Request generated: ``` insert @ https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&prettyPrint=true ``` RequestError: ``` Google.Apis.Request.RequestErrorNotFound[404]Errors [Message[Not Found]Location[-] Reason[notFound] Domain[global]]] ``` Weird thing is that doing a GET at https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&prettyPrint=true does not return something, so it should be there. I hope that there is some awesome guy/girl out there which knows what to do! I'm completely stuck. Update Seems like I am receiving the same 404 error on CalendarList Google Api Explorer also: Url: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert Request: ``` POST https://www.googleapis.com/calendar/v3/users/me/calendarList?key={YOUR_API_KEY} Content-Type: application/json Authorization: Bearer ya29.AHES6ZQTj-D6uIMOWr_AoFYVvfefsEGcVvLvvMf4aKhgrdvQE25aVw X-JavaScript-User-Agent: Google APIs Explorer { "id": "hastalavista" } ``` Response: ``` 404 Not Found - Show headers - { "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "Not Found" } ], "code": 404, "message": "Not Found" } } ``` Does anyone know whether Google have changed the URL for this resource? And if yes, how I change the Google Calendar Api v3 to use the updated url ...?

Original source