小编pel*_*yal的帖子

使用c#.net创建使用Google Calendar Api v3的日历时出错404

我正在尝试使用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: …

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

5
推荐指数
1
解决办法
5761
查看次数