Channels: stop

Stop watching for changes to a resource. Try it now or see an example.

Request

HTTP request

POST https://www.googleapis.com/drive/v2/channels/stop

Request body

In the request body, supply data with the following structure:

{
  "id": string,
  "resourceId": string
}
Property name Value Description Notes
id string A UUID or similar unique string that identifies this channel.
resourceId string An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.

Response

If successful, this method returns an empty response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.Channel;

import java.io.IOException;

// ...

public class MyClass {

  // ...

  /**
   * Stop watching for changes to a resource.
   *
   * @param service Drive API service instance.
   * @param channelId ID of the channel to stop watching.
   * @param resourceId Resource ID of the channel to stop watching.
   */
  private static void stopChannel(Drive service, String channelId,
      String resourceId) {
    Channel channel = new Channel();
    channel.setId(channelId);
    channel.setResourceId(resourceId);
    try {
      service.channels().stop(channel).execute();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  // ...

}

PHP

Uses the PHP client library.

/**
 * Stop watching to a specific channel.
 *
 * @param Google_Service_Drive $service Drive API service instance.
 * @param String $channelId ID of the channel to stop.
 * @param String $resourceId Resource ID of the channel to stop.
 */
function stopChannel($service, $channelId, $resourceId) {
  $channel = new Google_Service_Drive_Channel();
  $channel->setId($channelId);
  $channel->setResourceId($resourceId);
  try {
    $service->channels->stop($channel);
  } catch(Exception $e) {
    print "An error occured: " . $e->getMessage();
  }
}

Python

Uses the Python client library.

from apiclient import errors
# ...

def stop_channel(service, channel_id, resource_id):
  """Stop watching to a specific channel.

  Args:
    service: Drive API service instance.
    channel_id: ID of the channel to stop.
    resource_id: Resource ID of the channel to stop.
  """
  body = {
    'id': channel_id,
    'resourceId': resource_id
  }
  try:
    return service.channels().stop(body=body).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

JavaScript

Uses the JavaScript client library.

/**
 * Stop watching to a specific channel.
 *
 * @param {String} channelId ID of the channel to stop.
 * @param {String} resourceId Resource ID of the channel to stop.
 */
function stopChannel(channelId, resourceId) {
  var request = gapi.client.drive.channels.stop({
    'id': channelId,
    'resourceId': resourceId
  });
  request.execute(function(resp){ });
}

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Send feedback about...

Drive REST API v2
Drive REST API v2