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?