Warning: This item is deprecated.
Deprecated - Use changes.getStartPageToken and changes.list to retrieve recent changes. Try it now or see an example.Request
HTTP request
GET https://www.googleapis.com/drive/v2/changes/changeId
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
changeId |
string |
The ID of the change. |
Optional query parameters | ||
driveId |
string |
The shared drive from which the change is returned. |
supportsAllDrives |
boolean |
Whether the requesting application supports both My Drives and shared drives.
(Default: false )
|
supportsTeamDrives |
boolean |
Deprecated use supportsAllDrives instead.
(Default: false )
|
teamDriveId |
string |
Deprecated use driveId instead. |
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.apps.readonly |
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 Changes 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.Change; import com.google.api.services.drive.model.File; import java.io.IOException; // ... public class MyClass { // ... /** * Print a single Change resource information. * * @param service Drive API service instance. * @param changeId ID of the Change resource to retrieve. */ private static void printChange(Drive service, String changeId) { try { Change change = service.changes().get(changeId).execute(); System.out.println("Changed file ID: " + change.getFileId()); if (change.getDeleted()) { System.out.println("File has been deleted"); } else { File changedFile = change.getFile(); System.out.println("Changed file Title: " + changedFile.getTitle()); } } 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 a single Change resource information. /// </summary> /// <param name="service">Drive API service instance.</param> /// <param name="changeId">ID of the Change resource to retrieve.</param> public static void PrintChange(DriveService service, String changeId) { try { Change change = service.Changes.Get(changeId).Execute(); Console.WriteLine("Changed file ID: " + change.FileId); if (change.Deleted.HasValue && (bool)change.Deleted) { Console.WriteLine("File has been deleted"); } else { File changedFile = change.File; Console.WriteLine("Changed file Title: " + changedFile.Title); } } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } } // ... }
PHP
Uses the PHP client library.
/** * Print a single Change resource information. * * @param Google_Service_Drive $service Drive API service instance. * @param String $changeId ID of the Change resource to retrieve. */ function printChange($service, $changeId) { try { $change = $service->changes->get($changeId); print "Changed file ID: " . $change->getFileId(); if ($change->getDeleted()) { print "File has been deleted"; } else { $changedFile = $change->getFile(); print "Changed file Title: " . $changedFile->getTitle(); } } catch (Exception $e) { print "An error occurred: " . $e->getMessage(); } }
Python
Uses the Python client library.
from apiclient import errors # ... def print_change(service, change_id): """Print a single Change resource information. Args: service: Drive API service instance. change_id: ID of the Change resource to retrieve. """ try: change = service.changes().get(changeId=change_id).execute() print 'Changed file ID: %s' % change['fileId'] if change['deleted']: print 'File has been deleted' else: file = change['file'] print 'Changed file Title: %s' % file['title'] except errors.HttpError, error: print 'An error occurred: %s' % error
JavaScript
Uses the JavaScript client library.
/** * Print a single Change resource information. * * @param {String} changeId ID of the Change resource to retrieve. */ function printChange(changeId) { var request = gapi.client.drive.changes.get({ 'changeId': changeId }); request.execute(function(resp) { if (resp.deleted) { console.log('File has been deleted'); } else { var file = resp.file; console.log('Changed file Title: ' + file.title); } }); }
Go
Uses the Go client library.
import ( "google.golang.org/drive/v2" "fmt" ) // PrintChange fetches and displays the change with the passed changeId func PrintChange(d *drive.Service, changeId string) error { c, err := d.Changes.Get(changeId).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return err } fmt.Printf("Changed file ID: %v\n", c.FileId) if c.Deleted { fmt.Printf("File has been deleted\n") } else { fmt.Printf("Changed file Title: %v\n", c.File.Title) } return nil }
Objective-C
Uses the Objective-C client library.
#import "GTLDrive.h" // ... + (void)printChangeWithService:(GTLServiceDrive *)service changeId:(NSString *)changeId { GTLQueryDrive *query = [GTLQueryDrive queryForChangesGetWithChangeId:changeId]; // queryTicket can be used to track the status of the request. GTLServiceTicket *queryTicket = [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLDriveChange *change, NSError *error) { if (error == nil) { NSLog(@"Current user name: %@", change.fileId); if ([change.deleted boolValue]) { NSLog(@"File has been deleted"); } else { GTLDriveFile *changedFile = change.file; NSLog(@"Changed file Title: %@", changedFile.title); } } else { NSLog(@"An error occurred: %@", error); } }]; } // ...
Try it!
Use the APIs Explorer below to call this method on live data and see the response.