Reputation: 979
Just having a difficult time figuring how to access files in folders using Googles Drive RESP API v3.
I know I can access files using the /children
in v2 of REST API
GET https://www.googleapis.com/drive/v2/files/folderId/children
According to migration notes for v3 of REST API
Duplicate and obsolete functionality has been removed. Examples:
- The Children and Parents collections have been removed. Use files.list instead.
From what I can gather children.list
was a function you could leverage if you used gapi.js
request = gapi.client.drive.children.list({
'folderId' : folderId,
'pageToken': nextPageToken
});
Again, following the notes children.list
should be substituted for files.list with ?q='parent_id'+in+parents
.
But what does that actually mean for REST API users?
GET https://www.googleapis.com/drive/v3/files?q={folderId}+in+parents
GET https://www.googleapis.com/drive/v3/files?q=parents(folderId)
GET https://www.googleapis.com/drive/v3/files?q=folderId
No matter what I try I just keep getting 400 error - invalid value in the q.
References:
Upvotes: 0
Views: 740
Reputation: 22286
The format is
https://content.googleapis.com/drive/v3/files?q=%270Bw3h_yCVtXbbQ2VEQkRNQ0J1YTg%27%20in%20parents
Note the single quote (%27) around the folder ID.
Upvotes: 1
Reputation: 201378
How about this modification?
I don't know whether I can understand your question. If I misunderstand your question, I'm sorry.
I think that q='parent_id'+in+parents
you use is correct. It means that a file list in the parent_id
is retrieved. But when I see your tested endpoint and query, there is a modification point that I thought that this might be the reason of error.
GET https://www.googleapis.com/drive/v3/files?q={folderId}+in+parents
GET https://www.googleapis.com/drive/v3/files?q='{folderId}'+in+parents
When I tried to run it without the single quotes, the following error was retrieved. So I thought that this might be the reason.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid Value"
}
}
If you have already used the single quotes in {folderId}
, and if this was not useful for you, I'm sorry.
Upvotes: 1