Asticode
Asticode

Reputation: 447

Incomplete list of parents using Google Drive API

I'm looking to develop a web application using Google Drive API but I'm facing problems retrieving parents information about a file.

I have a file called "File 1-1-1" that correspond to this path/tree structure :

"/Folder 1/Folder 1-1/File 1-1-1"

Let's say this file has the ID "1234".

When I ping Google API such as "https://www.googleapis.com/drive/v2/files/1234/parents", all I get is this :

{
  'kind' : 'drive#parentList',
  'etag' : etag,
  'selfLink' : selfLink,
  'items' : [
  {
    'kind' : 'drive#parentReference',
    'id' : '123', // ID of Folder 1-1
    'selfLink' : selfLink,
    'parentLink' : parentLink,
    'isRoot' : false
  }]
}

And that's it!!!

No reference to Folder 1!!

If I keep getting deeper in the tree structure, I have the same problem : only one parent is returned.

Is there anything I'm doing wrong?

Thanks for your help.

Cheers.

EDIT 1 :

I've already seen this question Google Drive API (PHP): some files missing parent reference but my files/folders are not shared so that's not the answer unfortunately...

Upvotes: 0

Views: 781

Answers (1)

Cheryl Simon
Cheryl Simon

Reputation: 46844

Parents returns the direct parent(s), not all ascendents. Folder 1 is the parent of Folder 1-1, not of File 1-1-1. To get all ascendents you need to walk the tree.

Upvotes: 4

Related Questions