Reputation: 89
I am trying to list all shared drives from googledrive using List drive java method. this is my code.
public static void getDriveId(String folderName, String oauthToken) throws Exception {
DriveList list ;
String pageToken = null;
GoogleCredential credential = new GoogleCredential();
credential.setAccessToken(oauthToken);
try {
_driveService = new Drive.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), credential).setApplicationName(appName).build();
} catch (GeneralSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
list = _driveService.drives().list().setQ(folderName).setFields("nextPageToken, drives(id, name)")
.execute();
System.out.println(list.toString());
}
I am setting Q parameter in query where foldername= "salesDrive"
Its giving me error like
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request {
"code" : 400,
"errors" : [ {
"domain" : "global",
"location" : "q",
"locationType" : "parameter",
"message" : "Invalid Value",
"reason" : "invalid"
} ],
"message" : "Invalid Value"
}
How can i set this q parameter inorder to display only specific shared drive details?
Upvotes: 0
Views: 373
Reputation: 26796
You are missing two things:
foldername
, you should specify name = 'foldername'
(please keep in mind that it should the name of the shared Drive, not a folder contained in this Drive)To search for a specific set of shared drives, set the useDomainAdminAccess parameter to true
Missing out on any of the steps above will result in an 400 error, as the one you received.
Upvotes: 0