2
votes

I've created project and registered it using https://code.google.com/apis/console (I've choosen "other" application type). Then I got "Client ID" for installed applications.

Then I went to console and created event, and authorised using oauth 2. https://developers.google.com/google-apps/calendar/v3/reference/events/insert Everything worked fine.

    POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  xxx
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "end": {
  "dateTime": "2013-1-16T10:00:00.000-07:00"
 },
 "start": {
  "dateTime": "2013-1-16T10:00:00.000-07:00"
 }
}

Response

200 OK

- Show headers -

{

 "kind": "calendar#event",
 "etag": "\"WANTVF5ixxZ04U_VtQ0AZ3MbAlM/Z2NhbDAwMDAxMzY1NjU0MzAwNTk1MDAw\"",
 "id": "2nsuis19mkp2q0uef54tl5nk68",
 "status": "confirmed",
 "htmlLink": "https://www.google.com/calendar/event?eid=Mm5zdWlzMTlta3AycTB1ZWY1NHRsNW5rNjggaXZhbjEzMzEzM0Bt",
 "created": "2013-04-11T04:25:00.000Z",
 "updated": "2013-04-11T04:25:00.595Z",
 "creator": {
  "email": "[email protected]",
  "displayName": "ivan rozhcov",
  "self": true
 },
 "organizer": {
  "email": "[email protected]",
  "self": true
 },
 "start": {
  "dateTime": "2013-01-16T21:00:00+04:00"
 },
 "end": {
  "dateTime": "2013-01-16T21:00:00+04:00"
 },
 "iCalUID": "[email protected]",
 "sequence": 0,
 "reminders": {
  "useDefault": true
 }
}

Then I copied id and updated this event. https://developers.google.com/google-apps/calendar/v3/reference/events/update update First time I got 200 response.

PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/2nsuis19mkp2q0uef54tl5nk68?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZRmo6pdxj8pY4NmzdI1estRNB-v87XV7xQHgyhrWHk2rzs3Ke8
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "end": {
  "dateTime": "2013-1-16T10:00:00.000-07:00"
 },
 "start": {
  "dateTime": "2013-1-16T10:00:00.000-07:00"
 }
}

But when I tried this again, I always got 400 error, error text is written below.

https://developers.google.com/google-apps/calendar/v3/reference/events/update update

400 Bad Request

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  123
content-type:  application/json; charset=UTF-8
date:  Wed, 10 Apr 2013 12:49:29 GMT
expires:  Wed, 10 Apr 2013 12:49:29 GMT
server:  GSE

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

Can anyone explain, if that's google.api bug, or maybe I'm mistaken somwhere?

I've tryed it from differret account and PC (throught Google APIs Explorer and python library with same result)

Today I've tried to reproduce that bug. But everring works fine now. I've created an issue in google code http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3371&thanks=3371&ts=1365599378 Still without answer.

I think it's was temporaru bug.

4

4 Answers

3
votes

400 almost always means a simple syntax error in your auth URL. The most common cause is that you’ve either failed to URL-escape your scope or redirect, or alternatively URL-escaped it more than once.

2
votes

Check this: Google Calendar API - can only update event once and this: Google Calendar api v3 re-update issue

Sequence number needs to be increased when you change date/time of event, that is the reason why you are getting 400 - Bad request.

This is how I solved it using java client library.

mGoogleCalendarEvent contains updated information about event. First, get sequence number of this event from GoogleCalendar:

mGoogleCalendarEvent.setSequence(mService.events().get(mCalendarId,mGoogleCalendarEvent.getId()).execute().getSequence());

And then perform update:

mService.events().update(mCalendarId, mGoogleCalendarEvent.getId(),mGoogleCalendarEvent).execute();
1
votes

I used patch instead of update and it works fine by now. But don't realy understand why update succeded first time and failed second and other times. Total mystery.

0
votes

Discovered the exact same problem when accessing the Google Calendar API with the Google APIs Client Library for Javascript. It happens if I try to update the start date of a calendar event. Updating the end data is no problem. Really weird.

Fortunately, I was able to fix the issue by replacing update with patch too.