Search code examples
ruby-on-railsrubygoogle-api-clientgoogle-calendar-api

How to use google-api-client-ruby calendar stop_channel


I am attempting to use the google-api-client-ruby gem to interface with Google calendar.

I have succesfully setup a channel to watch for events, but I'm struggling to use the stop_channel method to stop watching for events.

The source code looks like it takes a channel object, but if I create a channel object and pass it to the stop_channel method, I get:

Error - Google::Apis::ClientError: required: Required

My code..

channel = Google::Apis::CalendarV3::Channel.new(address: "https://www.google.com/", id: 1, type: "web_hook")
begin
  calendar_service.stop_channel(channel)
rescue => error
  puts error
end

Am I doing something wrong or is the gem not working?..


Solution

  • Your error Google::Apis::ClientError: required: Required means that the request is invalid and should not be retried without modification.

    Also, I have seen this sample code that uses stop_channel method.

    def stop_channel(channel_id, resource_id)
        channel = Google::Apis::CalendarV3::Channel.new(
          id: channel_id,
          resource_id: resource_id
        )
        service.stop_channel(channel)
    end