2014-01-17 53 views
1

我试图从父文件夹中获取所有文件/文件夹。从Google Drive中的ID文件夹获取儿童文件

我设法得到父文件夹的ID。当我尝试获取文件信息,我可以,如果我用的ID指示在本页面活生生的例子:https://developers.google.com/drive/v2/reference/files/get

但是,当我试图让与页面代码示例的任何文件数据:

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); 
    } 
    } 

我什么也没得到,除了收到此错误信息:

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" 
} 

如何ç我可以从文件/文件夹中获得任何数据和ID吗?

非常感谢您的提前和问候!

+0

这显示为链接到[我回答的问题](http://stackoverflow.com/questions/26511945/404-error-when-trying-to-get-document-metadata-via-the-google- drive-api/26727594#comment42099407_26727594),所以我认为如果10个月后你仍然有问题,我会指示你。 –

回答

1

404表示(1)ID错误或(2)您无权访问该文件夹。

要确认ID,请使用Try It https://developers.google.com/drive/v2/reference/files/get#try-it并查看是否可以检索该文件。

如果可行,请检查您的应用使用的用户和范围是否允许访问。

+0

嗨! 我试着用这个例子,我得到了文件的信息。 但是,当我使用Java代码时,我无法获取文件信息。 这是我使用的代码: 'String query =“'”+ FileId +“'in parents”; \t Files.List request = service.files().list().setQ(query); try { \t FileList files = request.execute(); \t result.addAll(files.getItems()); \t request.setPageToken(files.getNextPageToken()); catch(IOException e){ \t System.out.println(“发生错误:”+ e); \t request.setPageToken(null); \t} \t 谢谢! – user2606850

+0

你检查了我的建议吗? 此外,你应该启用http跟踪,并比较你的应用程序发送的http与http从Try It – pinoyyid

相关问题