Gets a specific revision. Try it now or see an example.
Request
HTTP request
GET https://www.googleapis.com/drive/v2/files/fileId/revisions/revisionId
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
fileId |
string |
The ID of the file. |
revisionId |
string |
The ID of the revision. |
Authorization
This request requires authorization with at least one of the following scopes:
Scope |
---|
https://www.googleapis.com/auth/drive |
https://www.googleapis.com/auth/drive.file |
https://www.googleapis.com/auth/drive.readonly |
https://www.googleapis.com/auth/drive.metadata.readonly |
https://www.googleapis.com/auth/drive.appdata |
https://www.googleapis.com/auth/drive.metadata |
https://www.googleapis.com/auth/drive.photos.readonly |
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
Do not supply a request body with this method.
Response
If successful, this method returns a Revisions 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.Revision; import java.io.IOException; // ... public class MyClass { // ... /** * Print information about the specified revision. * * @param service Drive API service instance. * @param fileId ID of the file to print revision for. * @param revisionId ID of the revision to print. */ private static void printRevision(Drive service, String fileId, String revisionId) { try { Revision revision = service.revisions().get( fileId, revisionId).execute(); System.out.println("Revision ID: " + revision.getId()); System.out.println("Modified Date: " + revision.getModifiedDate()); if (revision.getPinned()) { System.out.println("This revision is pinned"); } } 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>Print information about the specified revision.</summary> /// <param name="service">Drive API service instance.</param> /// <param name="fileId">ID of the file to print revision for.</param> /// <param name="revisionId">ID of the revision to print.</param> public static void PrintRevision(DriveService service, String fileId, String revisionId) { try { Revision revision = service.Revisions.Get(fileId, revisionId).Execute(); Console.WriteLine("Revision ID: " + revision.Id); Console.WriteLine("Modified Date: " + revision.ModifiedDate); if (revision.Pinned.HasValue && (bool)revision.Pinned) { Console.WriteLine("This revision is pinned"); } } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } } // ... }
PHP
Uses the PHP client library.
/** * Print information about the specified revision. * * @param Google_Service_Drive $service Drive API service instance. * @param String $fileId ID of the file to print revision for. * @param String $revisionId ID of the revision to print. */ function printRevision($service, $fileId, $revisionId) { try { $revision = $service->revisions->get($fileId, $revisionId); print "Revision ID: " . $revision->getId(); print "Modified Date: " . $revision->getModifiedDate(); if ($revision->getPinned()) { print "This revision is pinned"; } } catch (Exception $e) { print "An error occurred: " . $e->getMessage(); } }
Python
Uses the Python client library.
from apiclient import errors # ... def print_revision(service, file_id, revision_id): """Print information about the specified revision. Args: service: Drive API service instance. file_id: ID of the file to print revision for. revision_id: ID of the revision to print. """ try: revision = service.revisions().get( fileId=file_id, revisionId=revision_id).execute() print 'Revision ID: %s' % revision['id'] print 'Modified Date: %s' % revision['modifiedDate'] if revision.get('pinned'): print 'This revision is pinned' except errors.HttpError, error: print 'An error occurred: %s' % error
JavaScript
Uses the JavaScript client library.
/** * Print information about the specified revision. * * @param {String} fileId ID of the file to print revision for. * @param {String} revisionId ID of the revision to print. */ function printRevision(fileId, revisionId) { var request = gapi.client.drive.revisions.get({ 'fileId': fileId, 'revisionId': revisionId }); request.execute(function(resp) { console.log('Revision ID: ' + resp.id); console.log('Modified Date: ' + resp.modifiedDate); if (resp.pinned) { console.log('This revision is pinned'); } }); }
Go
Uses the Go client library.
import ( "google.golang.org/drive/v2" "fmt" ) // PrintRevision prints a given revision of a given file func PrintRevision(d *drive.Service, fileId string, revisionId string) error { r, err := d.Revisions.Get(fileId, revisionId).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return err } fmt.Printf("Revision ID: %v", r.Id) fmt.Printf("Revision modified Date: %v", r.ModifiedDate) if r.Pinned { fmt.Printf("Revision is pinned") } return nil }
Objective-C
Uses the Objective-C client library.
#import "GTLDrive.h" // ... + (void)printRevisionWithService:(GTLServiceDrive *)service fileId:(NSString *)fileId revisionId:(NSString *)revisionId { GTLQueryDrive *query = [GTLQueryDrive queryForRevisionsGetWithFileId:fileId revisionId:revisionId]; // queryTicket can be used to track the status of the request. GTLServiceTicket *queryTicket = [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLDriveRevision *revision, NSError *error) { if (error == nil) { NSLog(@"Revision ID: %@", revision.identifier); NSLog(@"Modified Date: %@", revision.modifiedDate.stringValue); if ([revision.pinned boolValue]) { NSLog(@"This revision is pinned"); } } else { NSLog(@"An error occurred: %@", error); } }]; } // ...
Try it!
Use the APIs Explorer below to call this method on live data and see the response.