Google Drive SDK

Comments: delete

Deletes a comment. Try it now or see an example.

Request

HTTP request

DELETE https://www.googleapis.com/drive/v2/files/fileId/comments/commentId

Parameters

Parameter name Value Description
Path parameters
commentId string The ID of the comment.
fileId string The ID of the file.

Request body

Do not supply a request body with this method.

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 java.io.IOException;
// ...

public class MyClass {

  // ...

  /**
   * Remove a comment.
   *
   * @param service Drive API service instance.
   * @param fileId ID of the file to remove the comment for.
   * @param commentId ID of the comment to remove.
   */
  private static void removeComment(Drive service, String fileId,
      String commentId) {
    try {
      service.comments().delete(fileId, commentId).execute();
    } catch (IOException e) {
      System.out.println("An error occurred: " + e);
    }
  }

  // ...

}

.NET

Uses the .NET client library

using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;

using System.Net;
// ...

public class MyClass {

  // ...

  /// <summary>
  /// Remove a comment.
  /// </summary>
  /// Drive API service instance.
  /// ID of the file to remove the comment for.
  /// ID of the comment to remove.
  public static void RemoveComment(DriveService service, String fileId,
      String commentId) {
    try {
      service.Comments.Delete(fileId, commentId).Fetch();
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
  }

  // ...

}

PHP

Uses the PHP client library

/**
 * Remove a comment.
 *
 * @param Google_DriveService $service Drive API service instance.
 * @param String $fileId ID of the file to remove the comment for.
 * @param String $commentId ID of the comment to remove.
 */
function removeComment($service, $fileId, $commentId) {
  try {
    $service->comments->delete($fileId, $commentId);
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
}

Python

Uses the Python client library

from apiclient import errors
# ...

def remove_comment(service, file_id, comment_id):
  """Remove a comment.

  Args:
    service: Drive API service instance.
    file_id: ID of the file to remove the comment for.
    comment_id: ID of the comment to remove.
  """
  try:
    service.comments().delete(
        fileId=file_id, commentId=comment_id).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

Ruby

Uses the Ruby client library

##
# Remove a comment
#
# @param [Google::APIClient] client
#   Authorized client instance
# @param [String] file_id
#   ID of the file to remove the comment for
# @param [String] comment_id
#   ID of the comment to remove
# @return nil
def remove_comment(client, file_id, comment_id)

  drive = client.discovered_api('drive', 'v2')
  result = client.execute(
    :api_method => drive.comments.delete,
    :parameters => {
      'fileId' => file_id,
      'commentId' => comment_id })
  if result.status != 200
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

JavaScript

Uses the JavaScript client library

/**
 * Remove a comment.
 *
 * @param {String} fileId ID of the file to remove the comment for.
 * @param {String} commentId ID of the comment to remove.
 */
function removeComment(fileId, commentId) {
  var request = gapi.client.drive.comments.delete({
    'fileId': fileId,
    'commentId': commentId
  });
  request.execute(function(resp) { });
}

Try it!

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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.