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'})
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With