Get childrens files from an ID folder in Google Drive

拥有回忆 提交于 2019-12-24 16:14:53

问题


I'm trying to get all the files / folders from a parent folder.

I managed to get the ID of the parent folder. When I try to get the file information, I can, if I Use the ID as indicated on this page live example : https://developers.google.com/drive/v2/reference/files/get

However, when I try to get any file data with the page code sample :

  try {
      File file = service.files().get(fileId).execute();

      System.out.println("Title: " + file.getTitle());
      System.out.println("Description: " + file.getDescription());
      System.out.println("MIME type: " + file.getMimeType());
    } catch (IOException e) {
      System.out.println("An error occured: " + e);
    }
  }

I get nothing, except get this error message :

com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 OK

{
  "code" : 404,
  "errors" : [ {
    "domain" : "global",
    "message" : "File not found: 0Bz8fRNYAOdjjd05ydVRCROE4QlE",
    "reason" : "notFound"
  } ],
  "message" : "File not found: 0Bz8fRNYAOdjjd05ydVRCROE4QlE"
}

How could I get any data from the file / folder with its ID?

Thank you very much in advance and greetings !


回答1:


404 means either (1) the ID is wrong, or (2) you don't have permission to access that folder.

To confirm the ID, use Try It at https://developers.google.com/drive/v2/reference/files/get#try-it and see if the file can be retrieved.

If this works, check that the user and scope that your app is using allow access.



来源:https://stackoverflow.com/questions/21188752/get-childrens-files-from-an-id-folder-in-google-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!