Replies: update

Stay organized with collections Save and categorize content based on your preferences.

Updates an existing reply. Try it now or see an example.

Request

HTTP request

PUT 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.

Authorization

This request allows authorization with at least one of the following scopes:

Scope
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file

Some scopes are restricted and require a security assessment for your app to use them. For more information, see the authentication and authorization page.

Request body

In the request body, supply a Replies resource with the following properties:

Property name Value Description Notes
Required Properties
content string The plain text content used to create this reply. This is not HTML safe and should only be used as a starting point to make edits to a reply's content. This field is required on inserts if no verb is specified (resolve/reopen). writable
Optional Properties
verb string The action this reply performed to the parent comment. When creating a new reply this is the action to be perform to the parent comment. Possible values are:
  • "resolve" - To resolve a comment.
  • "reopen" - To reopen (un-resolve) a comment.
writable

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 {

  // ...

  /**
   * Update 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 update.
   * @param newContent The new text content for the reply.
   * @return The updated reply if successful, {@code null} otherwise.
   */
  private static CommentReply updateReply(Drive service, String fileId,
      String commentId, String replyId, String newContent) {
    try {
      // First retrieve the reply from the API.
      Reply reply = service.replies().get(
          fileId, commentId, replyId).execute();
      reply.setContent(newContent);
      return service.replies().update(
          fileId, commentId, replyId, reply).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>
  /// Update a reply to a comment.
  /// </summary>
  /// <param name="service">Drive API service instance.</param>
  /// <param name="fileId">ID of the file to update reply for.</param>
  /// <param name="commentId">ID of the comment to update reply for.</param>
  /// <param name="replyId">ID of the reply to update.</param>
  /// <param name="newContent">The new text content for the reply.</param>
  /// <returns>The updated reply, null is returned if an API error occurred</returns>
  public static CommentReply UpdateReply(DriveService service, String fileId,
      String commentId, String replyId, String newContent) {
    try {
      // First retrieve the reply from the API.
      CommentReply reply = service.Replies.Get(fileId, commentId, replyId).Execute();
      reply.Content = newContent;
      return service.Replies.Update(reply, fileId, commentId, replyId).Execute();
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
    return null;
  }

  // ...

}

PHP

Uses the PHP client library.

/**
 * Update a reply's content.
 *
 * @param Google_Service_Drive $service Drive API service instance.
 * @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 update.
 * @param String $newContent The new text content for the reply.
 * @return Google_Servie_Drive_CommentReply The updated reply. NULL is returned
 *     if an API error occurred.
 */
function updateReply($service, $fileId, $commentId, $replyId, $newContent) {
  try {
    // First retrieve the reply from the API.
    $reply = $service->replies->get($fileId, $commentId, $replyId);
    $reply->setContent($newContent);
    return $service->replies->update($fileId, $commentId, $replyId, $reply);
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
  return NULL;
}

Python

Uses the Python client library.

from apiclient import errors
# ...

def update_reply(service, file_id, comment_id, reply_id, new_content):
  """Update a reply to a comment.

  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 update.
    new_content: The new text content for the reply.

  Returns:
    The updated reply if successful, None otherwise.
  """
  try:
    # First retrieve the reply from the API.
    reply = service.replies().get(
        fileId=file_id, commentId=comment_id, replyId=reply_id).execute()
    reply['content'] = new_content
    return service.replies().update(
        fileId=file_id, commentId=comment_id,
        replyId=reply_id, body=reply).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error
  return None

JavaScript

Uses the JavaScript client library.

/**
 * Update 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 update.
 * @param {String} newContent The new text content for the reply.
 */
function updateReply(fileId, commentId, replyId, newContent) {
  // First retrieve the reply from the API.
  var request = gapi.client.drive.replies.get({
    'fileId': fileId,
    'commentId': commentId,
    'replyId': replyId
  });
  request.execute(function(resp) {
    resp.content = newContent;
    var updateRequest = gapi.client.drive.replies.update({
      'fileId': fileId,
      'commentId': commentId,
      'replyId': replyId,
      'resource': resp
    });
    updateRequest.execute(function(resp) { });
  });
}

Try it!

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