如果日历尚不存在,我正在尝试使用 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
}
生成的请求:
insert @ https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&prettyPrint=true
请求错误:
Google.Apis.Request.RequestErrorNotFound[404]Errors [Message[Not Found]Location[-] Reason[notFound] Domain[global]]]
奇怪的是在https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&prettyPrint=true做一个 GET不会返回一些东西,所以它应该在那里。
我希望那里有一些很棒的男孩/女孩知道该怎么做!我完全被困住了。
更新 似乎我在 CalendarList Google Api Explorer 上也收到了相同的 404 错误:
网址: https ://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert
要求:
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"
}
回应:
404 Not Found
- Show headers - { "error": { "errors": [ {
"domain": "global",
"reason": "notFound",
"message": "Not Found" } ], "code": 404, "message": "Not Found" } }
有谁知道 Google 是否更改了此资源的 URL?如果是,我如何更改 Google Calendar Api v3 以使用更新后的 url ...?