2012-06-15 69 views
3

我對java使用google-api-services-calendar v3。在Google日曆API v3中插入新的calendarEntry返回404

我列出沒有問題我的calendarEntries。但插入新的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" 
} 
} 

任何想法?

+0

HII u能PLZ告訴我如何可以插入在谷歌日曆事件我不能understand.if u有一些代碼,然後plz向我。我有谷歌的示例代碼? API,但不能理解這一點。 – Google

回答

3

RTFM!

我不在好的uri上。正確的插入必須在https://www.googleapis.com/calendar/v3/calendars

而不是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(); 
    } 
+0

這個URL開關使用最新的Python API爲我解決了它。任何想法爲什麼不正確的URL被廣告?你有沒有參考上述「手冊」? – Attie

相關問題