I'm able to retrieve all the files inside of my root folder using this code:
FileList result = driveService.files().list()
.setPageSize(100)
.setFields("nextPageToken, files(id, name)")
.execute();
However I would like to return only the files inside the "test" folder under root, but this fails:
FileList result = driveService.files().list().setQ("test in parents")
.setPageSize(100)
.setFields("nextPageToken, files(id, name)")
.execute();
with this error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
GET https://www.googleapis.com/drive/v3/files?fields=nextPageToken, files(id, name)&pageSize=100&q=test in parents
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"location" : "q",
"locationType" : "parameter",
"message" : "Invalid Value",
"reason" : "invalid"
} ],
"message" : "Invalid Value"
}
Any idea what I'm doing wrong?
CodePudding user response:
You missed the quotes around test
.
And test
cannot be the folder name, but the folder id.
'FOLDER_ID' in parents