我使用 google-api-services-calendar v3 for java。
我毫无问题地列出了我的日历条目。但是插入新的calendarEntry失败。
我使用与示例相同的代码:
CalendarListEntry newCal = new CalendarListEntry();
newCal.setId(calTitle);
newCal.setSummary(calTitle);
newCal.setTimeZone("Europe/Paris");
CalendarListEntry execute = null;
try {
execute = service.calendarList().insert(newCal).execute();
} catch (IOException e) {
e.printStackTrace();
}
未创建日历。在日志中我有:
CONFIG: {"id":"A_TEST","summary":"A_TEST","timeZone":"Europe/Paris"}
15 juin 2012 16:20:45 com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://www.googleapis.com/calendar/v3/users/me/calendarList
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: Google-HTTP-Java-Client/1.10.2-beta (gzip)
Content-Type: application/json; charset=UTF-8
Content-Encoding: gzip
Content-Length: 69
CONFIG: Total: 60 bytes
CONFIG: {"id":"A_TEST","summary":"A_TEST","timeZone":"Europe/Paris"}
15 juin 2012 16:20:46 com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 404 Not Found
X-Frame-Options: SAMEORIGIN
Date: Fri, 15 Jun 2012 14:07:52 GMT
Content-Length: 120
Expires: Fri, 15 Jun 2012 14:07:52 GMT
X-XSS-Protection: 1; mode=block
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Server: GSE
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
CONFIG: Total: 165 bytes
CONFIG: {
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
有任何想法吗?
RTFM!
我不在好的uri上。正确插入必须打开https://www.googleapis.com/calendar/v3/calendars https://www.googleapis.com/calendar/v3/calendars
and not https://www.googleapis.com/calendar/v3/users/me/calendarList https://www.googleapis.com/calendar/v3/users/me/calendarList.
代码是:
Calendar newCal = new Calendar();
newCal.setSummary(calTitle);
newCal.setTimeZone("Europe/Paris");
Calendar createdCalendar = null;
try {
createdCalendar = service.calendars().insert(newCal).execute();
} catch (Exception e){
e.printStackTrace();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)