我正在尝试使用Google Calendar API v3创建日历,如果它还不存在的话.我的实现成功检索了我的所有日历和事件,并可以更改日历,但我正在努力添加新日历.这是我为了尝试为用户添加新日历而做的事情:
...
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
}
Run Code Online (Sandbox Code Playgroud)
请求生成:
insert @ https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&prettyPrint=true
Run Code Online (Sandbox Code Playgroud)
RequestError: …