Google Calendar API v3-更新事件 [英] Google Calendar API v3 - Update Event
问题描述
我正在使用google-api-ruby-client处理Google Calendar API v3.
我面临的唯一问题是两次更新事件.
之前已在此处进行了讨论( Google Calendar api v3重新更新问题),但没有ruby客户,也没有答案.
添加新事件时,我会得到一个ID和一个ETAG.我使用ID更新事件,并获得了一个新的ETAG.现在,如果我尝试第二次更新,它不会更新,并显示400错误消息"Invalid Value".
第二次更新时,我必须发送最新的ETAG,但是我不确定在使用google-api-ruby-client时如何发送.
这是代码:
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'})
文档对此确实很粗略,但是似乎您每次执行更新时都必须增加sequence
属性.这是一个版本控制机制.
http://www.kanzaki.com/docs/ical/sequence.html >
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
这篇关于Google Calendar API v3-更新事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!