4

I use the google-api-services-calendar v3 for java.

I list without problems my calendarEntries. But the insertion of a new calendarEntry fails.

I use the same code as the samples :

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();
}

The calendar is not created. In the logs I have :

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"
 }
}

Any ideas?

GaetanZ
  • 2,819
  • 3
  • 21
  • 20
  • hii can u plz tell me how can i insert the event in google calendar?i cant understand.if u have some code then plz send me.i have sample code of google api but cant understand this. – Google Jul 15 '13 at 06:27

1 Answers1

3

RTFM!

I was not on the good uri. The correct insertion must be on https://www.googleapis.com/calendar/v3/calendars

and not https://www.googleapis.com/calendar/v3/users/me/calendarList.

The code is :

    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();
    }
GaetanZ
  • 2,819
  • 3
  • 21
  • 20
  • This URL switch fixed it for me using the latest Python API. Any ideas why the incorrect URL is being advertised? Do you have reference to the aforementioned "manual"? – Attie Oct 18 '17 at 12:04