Google Calendar API v3 - Update Event

google-calendar-api, ruby, ruby-on-rails

Solution

The docs are really sketchy on this but it seems you have to increment the `sequence` property each time you do an update. It's a revision control mechanism.

http://www.kanzaki.com/docs/ical/sequence.html

Problem

I'm using google-api-ruby-client for working with Google Calendar API v3. The only problem I'm facing is with updating an event twice. It has been discussed here before (Google Calendar api v3 re-update issue) but without ruby client and no answer. When I add a new event I get an ID and an ETAG. I use ID to update the event and I get a new ETAG. Now If I try to update 2nd time, it doesn't update and sends 400 error with message "Invalid Value". I have to send latest ETAG when updating 2nd time but I'm not sure how to send that when working with google-api-ruby-client. Here's the code: ``` event = { 'summary' => "Summary", 'location' => "Location", 'description' => "Description", 'start' => { 'dateTime' => @entry.from_date }, 'end' => { 'dateTime' => @entry.to_date } } result = client.execute(:api_method => service.events.update, :parameters => {'calendarId' => @entry.calendar.gid, 'eventId'=>@entry.gid}, :body => JSON.dump(event), :headers => {'Content-Type' => 'application/json'}) ```

Original source

Related problems