Certain Files Missing In Google Drive Api V3 Python Files().list()
I'm new to using the Google Drive API for Python (v3) and I've been trying to access and update the sub-folders in a particular parent folder for which I have the fileId. Here is m
Solution 1:
I figured out the error with my code:
My previous query parameter in the files().list()
method was:
results = service.files().list(
q="parents in '1QXPl6z04GsYAO0GKHBk2oBjEweaAbczw'",
fields="files(id, name), incompleteSearch, nextPageToken").execute()
items = results['files']
After looking at another bug someone had posted in Google's issue tracker for the API, I saw the preferred syntax for that query was:
results = service.files().list(
q="'1QXPl6z04GsYAO0GKHBk2oBjEweaAbczw' in parents",
fields="files(id, name), incompleteSearch, nextPageToken").execute()
items = results['files']
In other words switching the order of parents in fileId
to fileId in parents
. With the resulting change in syntax all 41 files were returned.
I have two follow-up questions that hopefully someone can clarify:
- Why would the first syntax return any records at all if it is incorrect? And why would changing the name of a file prevent it from being returned using the first syntax?
- If you wanted to return a list of files that were stored in one of a few folders, is there any way to pass multiple parent ids to the query as the
parents in ...
syntax would suggest? Or do they have to be evaluated as separate conditions i.e.fileId1 in parents or fileId2 in parents
?
If someone could comment on this answer with those explanations or post a more complete answer, I would gladly select it as the best response.
Post a Comment for "Certain Files Missing In Google Drive Api V3 Python Files().list()"