Find file's parent id : Google Drive API V3

akgaur picture akgaur · Dec 14, 2015 · Viewed 16.2k times · Source

enter image description here

Today after I updated my Drive API to V3, I dint find any method to find the parent of the selected file . Is the rest endpoint to fetch json related to parent's info changed?

Answer

Dan McGrath picture Dan McGrath · Dec 15, 2015

Congrats, you found the Google Drive API version 3 several hours before we officially announced it. :)

In v3, there is no longer a parents collection. Instead, you get the parents property by doing a files.get with the child's ID. Ideally, you would use the fields parameter to restrict the response to just the parent(s). Note: A file may have more than one parent, so be prepared to handle multiple parents.

You can get a sense of the changes from v2 to v3 by looking at the migration cheat sheet.