Here's the most simplified way to show the problem that I can find. I do this at a breakpoint in my app. I waited about a minute after any other calls, my calendar is not open anywhere else, etc.
In one case when I did this, a second call to events.update worked (and it still had the same etag that had just failed!)
--> (rdb:30) remote_event = google_client.client.execute( :api_method => google_client.calendar_service.events.get, :parameters => {'calendarId' => record.calendar_id, 'eventId' =>
remote_event.id}).data
#<Google::APIClient::Schema::Calendar::V3::Event:0x3ff27b0eabc0 DATA:{"kind"=>"calendar#event", "etag"=>"\"xxxxx\"", "id"=>"xxxxx", "status"=>"confirmed", "htmlLink"=>"
https://www.google.com/calendar/event?eid=xxxxx", "created"=>"2012-04-23T19:13:19.000Z", "updated"=>"2012-04-24T16:12:00.000Z", "summary"=>"0", "creator"=>{"email"=>"
xx...@gmail.com"}, "organizer"=>{"email"=>"
xx...@group.calendar.google.com", "displayName"=>"Kitchen"}, "start"=>{"dateTime"=>"2012-04-24T14:00:00Z", "timeZone"=>"America/Los_Angeles"}, "end"=>{"dateTime"=>"2012-04-24T15:00:00Z", "timeZone"=>"America/Los_Angeles"}, "iCalUID"=>"
xx...@google.com", "sequence"=>19, "reminders"=>{"useDefault"=>true}}>
--> (rdb:30) google_client.client.execute( :api_method => google_client.calendar_service.events.update, :parameters => {'calendarId' => record.calendar_id, 'eventId' =>
remote_event.id}, :body => JSON.dump(remote_event), :headers => {'Content-Type' => 'application/json', 'If-Match' => remote_event.etag}).data
#<Google::APIClient::Schema::Calendar::V3::Event:0x3ff279a17d44 DATA:{"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"conditionNotMet", "message"=>"Precondition Failed", "locationType"=>"header", "location"=>"If-Match"}], "code"=>412, "message"=>"Precondition Failed"}}>
On Tuesday, April 24, 2012 8:46:38 AM UTC-7, Mac Martine wrote:
Ah. My events_get calls look fine from what I can tell. Here's the result of an events_get call (I just replaced some long codes with 'x''s) where the subsequent events_update call failed with a 412.
#<Google::APIClient::Schema::Calendar::V3::Event:0x3fc2ce2de1c0 DATA:{"kind"=>"calendar#event", "etag"=>"\"c5Pj5ZZfo_-lyDNwU2zL3j-mMCM/Q0pENmtLanVKaEVBQUFBQUFBQUFBQT09\"", "id"=>"xxxxx", "status"=>"confirmed", "htmlLink"=>"https://www.google.com/calendar/event?eid=xxxxx", "created"=>"2012-04-23T19:13:19.000Z", "updated"=>"2012-04-24T15:42:02.000Z", "summary"=>"1", "creator"=>{"email"=>"xxxxx@gmail.com"}, "organizer"=>{"email"=>"xxxxx@group.calendar.google.com", "displayName"=>"Kitchen"}, "start"=>{"dateTime"=>"2012-04-24T18:00:00Z", "timeZone"=>"America/Los_Angeles"}, "end"=>{"dateTime"=>"2012-04-24T19:00:00Z", "timeZone"=>"America/Los_Angeles"}, "iCalUID"=>"xx...@google.com", "sequence"=>17, "reminders"=>{"useDefault"=>true}}>