Google Drive SDK

Replies: list

Lists all of the replies to a comment. Try it now or see an example.

Request

HTTP request

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

Parameters

Parameter name Value Description
Path parameters
commentId string The ID of the comment.
fileId string The ID of the file.
Optional query parameters
includeDeleted boolean If set, all replies, including deleted replies (with content stripped) will be returned. (Default: false)
maxResults integer The maximum number of replies to include in the response, used for paging. Acceptable values are 0 to 100, inclusive. (Default: 20)
pageToken string The continuation token, used to page through large result sets. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "kind": "drive#commentReplyList",
  "selfLink": string,
  "nextPageToken": string,
  "nextLink": string,
  "items": [
    replies Resource
  ]
}
Property name Value Description Notes
kind string This is always drive#commentReplyList.
nextPageToken string The token to use to request the next page of results.
items[] list List of reply.

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.CommentReply;
import com.google.api.services.drive.model.CommentReplyList;

import java.io.IOException;
import java.util.List;

// ...

public class MyClass {

  // ...

  /**
   * Retrieve a list of replies.
   *
   * @param service Drive API service instance.
   * @param fileId ID of the file to retrieve replies for.
   * @param commentId ID of the comment to retrieve replies for.
   * @return List of replies.
   */
  private static List<CommentReply> retrieveReplies(Drive service,
      String fileId, String commentId) {
    try {
      CommentReplyList replies = service.replies().list(fileId, commentId).execute();
      return replies.getItems();
    } catch (IOException e) {
      System.out.println("An error occurred: " + e);
    }
    return null;
  }

  // ...

}

.NET

Uses the .NET client library

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

using System.Collections.Generic;
// ...

public class MyClass {

  // ...

  /// <summary>
  /// Retrieve a list of replies.
  /// </summary>
  /// Drive API service instance.
  /// ID of the file to retrieve replies for.
  /// ID of the comment to retrieve replies for.
  /// List of replies.
  public static IList<CommentReply> RetrieveReplies(
      DriveService service, String fileId, String commentId) {
    try {
      CommentReplyList replies = service.Replies.List(fileId, commentId).Fetch();
      return replies.Items;
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
    return null;
  }

  // ...

}

PHP

Uses the PHP client library

/**
 * Retrieve a list of replies.
 *
 * @param Google_DriveService $service Drive API service instance.
 * @param String $fileId ID of the file to retrieve replies for.
 * @param String $commentId ID of the comment to retrieve replies for.
 * @return Array List of Google_CommentReply resources.
 */
function retrieveReplies($service, $fileId, $commentId) {
  try {
    $replies = $service->replies->listReplies($fileId, $commentId);
    return $replies->getItems();
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
  return NULL;
}

Python

Uses the Python client library

from apiclient import errors
# ...

def retrieve_replies(service, file_id, comment_id):
  """Retrieve a list of replies to a comment.

  Args:
    service: Drive API service instance.
    file_id: ID of the file to retrieve replies for.
    comment_id: ID of the comment to retrieve replies for.
  Returns:
    List of replies.
  """
  try:
    replies = service.replies().list(
        fileId=file_id, commentId=comment_id).execute()
    return replies.get('items', [])
  except errors.HttpError, error:
    print 'An error occurred: %s' % error
  return None

Ruby

Uses the Ruby client library

##
# Retrieve a list of replies
#
# @param [Google::APIClient] client
#   Authorized client instance
# @param [String] file_id
#   ID of the file to retrieve replies for
# @param [String] comment_id
#   ID of the comment to retrieve replies for
# @return [Array]
#   List of replies
def retrieve_replies(client, file_id, comment_id)
  drive = client.discovered_api('drive', 'v2')
  api_result = client.execute(
    :api_method => drive.replies.list,
    :parameters => {
      'fileId' => file_id,
      'commentId' => comment_id
    })
  if api_result.status == 200
    replies = api_result.data
    return replies.items
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

JavaScript

Uses the JavaScript client library

/**
 * Retrieve a list of replies.
 *
 * @param {String} fileId ID of the file to retrieve replies for.
 * @param {String} commentId ID of the comment to retrieve replies for.
 * @param {Function} callback Function to call when the request is complete.
 */
function retrieveReplies(fileId, commentId, callback) {
  var request = gapi.client.drive.replies.list({
    'fileId': fileId,
    'commentId': commentId
  });
  request.execute(callback);
}

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.