Google Drive API:没有使用drive.files.get的父母

时间:2017-06-02 15:16:32

标签: google-drive-api

我正在使用Google Drive API。我可以使用drive.files.list API方法获取文件列表。以下是调用此方法的结果:

{
 "files": [
  {
   "id": "1yLJFT2bHhsz1WxJX29mD9DiNz0vLDlBvzJf5GJCcboI",
   "mimeType": "application/vnd.google-apps.spreadsheet",
   "parents": [
    "0Bwy7SlKkxnwQRld6RWljU0Y4TG8"
   ]
  },
  {
   "id": "0Bwy7SlKkxnwQVXdBRmlPMGNoTmM",
   "mimeType": "application/vnd.google-apps.folder",
   "parents": [
    "0B4jAnSzS-VxlZW9RcDJheU5FYW8"
   ]
  },
  {
   "id": "0Bwy7SlKkxnwQRld6RWljU0Y4TG8",
   "mimeType": "application/vnd.google-apps.folder",
   "parents": [
    "0Bwy7SlKkxnwQQndiQnYxbUF4SjQ"
   ]
  }]
}

当我使用drive.files.get API调用请求单个文件时,我希望获得与上面列表中显示的相同的结果。我在请求列出的第一个和第三个文件时这样做。例如:

获取https://www.googleapis.com/drive/v3/files/0Bwy7SlKkxnwQRld6RWljU0Y4TG8?supportsTeamDrives=true&fields=id%2CmimeType%2Cparents

结果:

{
 "id": "0Bwy7SlKkxnwQRld6RWljU0Y4TG8",
 "mimeType": "application/vnd.google-apps.folder",
 "parents": [
  "0Bwy7SlKkxnwQQndiQnYxbUF4SjQ"
 ]
}

这与列表中显示的内容相同。但由于某些原因,当我在列表中请求第二个文件时,结果中缺少父列表:

获取https://www.googleapis.com/drive/v3/files/0Bwy7SlKkxnwQVXdBRmlPMGNoTmM?supportsTeamDrives=true&fields=id%2CmimeType%2Cparents

结果:

{
 "id": "0Bwy7SlKkxnwQVXdBRmlPMGNoTmM",
 "mimeType": "application/vnd.google-apps.folder"
}

没有父母阵列。谁能解释这种行为?我假设所有文件都应该有父文件。

1 个答案:

答案 0 :(得分:1)

如果您还没有完成,可能需要检查您是否有权访问第二个文件的父级。如Enabling Team Drives中所述:

  

如果请求用户不是Team Drive的成员且无权访问父级,则父级不会出现在父级列表中。

Behavioral differences中,与权限和所有权相关的字段的填充方式不同。

相关问题