Google Drive SDK

Replies: patch

Updates an existing reply. This method supports patch semantics. Try it now or see an example.

Request

HTTP request

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

Parameters

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

Request body

In the request body, supply a Replies resource.

Response

If successful, this method returns a Replies resource in the 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.CommentReply;

import java.io.IOException;
// ...

public class MyClass {

  // ...

  /**
   * Patch a reply's content.
   *
   * @param service Drive API service instance.
   * @param fileId ID of the file to update reply for.
   * @param commentId ID of the comment to update reply for.
   * @param replyId ID of the reply to patch.
   * @param newContent The new text content for the reply.
   * @return The patched reply if successful, {@code null} otherwise.
   */
  private static CommentReply patchReply(Drive service, String fileId,
      String commentId, String replyId, String newContent) {
    CommentReply patchedReply = new CommentReply();
    patchedReply.setContent(newContent);
    try {
      return service.replies().patch(
          fileId, commentId, replyId, patchedReply).execute();
    } 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.Net;
// ...

public class MyClass {

  // ...

  /// <summary>
  /// Patch a reply's content.
  /// </summary>
  /// Drive API service instance.
  /// ID of the file to update reply for.
  /// ID of the comment to update reply for.
  /// ID of the reply to patch.
  /// The new text content for the reply.
  /// The patched reply, null is returned if an API error occurred
  public static CommentReply PatchReply(DriveService service, String fileId,
      String commentId, String replyId, String newContent) {
    CommentReply patchedReply = new CommentReply();
    patchedReply.Content = newContent;
    try {
      return service.Replies.Patch(patchedReply, fileId, commentId, replyId).Fetch();
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
    return null;
  }

  // ...

}

PHP

Uses the PHP client library

/**
 * Patch a reply's content.
 *
 * @param Google_DriveService $service Drive API service instance.
 * @param String $fileId ID of the file to patch reply for.
 * @param String $commentId ID of the comment to patch reply for.
 * @param String $replyId ID of the reply to patch.
 * @param String $newContent The new text content for the reply.
 * @return Google_CommentReply The patched reply. NULL is returned if an API error occurred.
 */
function patchReply($service, $fileId, $commentId, $replyId, $newContent) {
  $patchedReply = new Google_CommentReply();
  $patchedReply->setContent(newContent);
  try {
    return $service->replies->patch($fileId, $commentId, $replyId, $patchedReply);
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
  return NULL;
}

Python

Uses the Python client library

from apiclient import errors
# ...

def patch_reply(service, file_id, comment_id, reply_id, new_content):
  """Patch a reply's content.

  Args:
    service: Drive API service instance.
    file_id: ID of the file to update reply for.
    comment_id: ID of the comment to update reply for.
    reply_id: ID of the reply to patch.
    new_content: The new text content for the reply.

  Returns:
    The patched reply if successful, None otherwise.
  """
  patched_reply = {'content': new_content}
  try:
    return service.replies().patch(
        fileId=file_id, commentId=comment_id,
        replyId=reply_id, body=patched_reply).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error
  return None

Ruby

Uses the Ruby client library

##
# Patch a reply's content
#
# @param [Google::APIClient] client
#   Authorized client instance
# @param [String] file_id
#   ID of the file to update reply for
# @param [String] comment_id
#   ID of the comment to update reply for
# @param [String] reply_id
#   ID of the reply to patch
# @param [String] new_content
#   The new text content for the reply
# @return [Google::APIClient::Schema::Drive::V2::Reply]
#   The patched reply if successful, nil otherwise
def patch_reply(client, file_id, comment_id, reply_id, new_content)
  drive = client.discovered_api('drive', 'v2')
  patched_reply = drive.replies.patch.request_schema.new({
    'content' => new_content
  })
  result = client.execute(
    :api_method => drive.replies.patch,
    :body_object => patched_reply,
    :parameters => {
      'fileId' => file_id,
      'commentId' => comment_id,
      'replyId' => reply_id
    })
  if result.status == 200
    return result.data
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

JavaScript

Uses the JavaScript client library

/**
 * Patch a reply's content.
 *
 * @param {String} fileId ID of the file to update reply for.
 * @param {String} commentId ID of the comment to update reply for.
 * @param {String} replyId ID of the reply to patch.
 * @param {String} newContent The new text content for the reply.
 */
function patchReply(fileId, commentId, replyId, newContent) {
  var body = {'content': newContent};
    var request = gapi.client.drive.replies.patch({
      'fileId': fileId,
      'commentId': commentId,
      'replyId': replyId,
      'resource': body
    });
    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.