谷歌日历API v3 - 更新事件

7
我正在使用google-api-ruby-client与Google Calendar API v3进行交互。
我面临的唯一问题是更新事件两次时出现错误。
这个问题曾经在这里讨论过(Google Calendar api v3 re-update issue),但没有Ruby客户端并且没有答案。
当我添加新事件时,我会得到一个ID和ETAG。我使用ID来更新事件,并获得一个新的ETAG。现在,如果我尝试第二次更新,它不会更新,并发送400错误消息“无效值”。
当第二次更新时,我必须发送最新的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'})
1个回答

10

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接