使用Drive REST API的文件().list()上的内部服务器错误500 [英] Internal Server Error 500 on files().list() with Drive REST API

查看:113
本文介绍了使用Drive REST API的文件().list()上的内部服务器错误500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:此问题似乎已解决。详情请参阅错误跟踪器报告





通过Drive REST API(v3)获取文件列表请求时没有发生
内部服务器错误(错误代码为500)试图通过调用
文件来使用名称 appProperties 键).list()在搜索标准中用名称 createdTime 作为排序顺序。 (这是
下面代码中的case 1。)我使用的语法记录为 REST Android快速入门项目
在这里找到了
,并对
进行了一些修改 getDataFromApi 方法,如下面的代码块所示。

有六种测试用例使用各种搜索条件和排序组合订单字段。有些查询成功,而
其他则失败,服务器代码为500,一次失败。这些结果在运行Android 7.0
和API 24的模拟器上是一致的。我的问题源自早期版本。



我最感兴趣的是获得解决方案案例1,并提供其他案例作为我试图找出哪里出了问题。

 私人列表< String>我会很感激任何帮助或想法,我可能会做错什么或可能发生了什么。 getDataFromApi()抛出IOException {
//获取最多10个文件的列表。
列表< String> fileInfo = new ArrayList< String>();
$ b $ / *案例1:崩溃并出现以下错误:
500内部服务器错误
{
code:500,
errors:[ {
domain:global,
message:内部错误,
reason:internalError
}],
消息:内部错误
} * /
String query =name contains'Test'而不是appProperties has {key ='X'and value ='Y'};
String orderBy =name,createdTime;

//案例2:成功并列出文件。
//与情况1类似,但createdTime按排序顺序排列。
// String query =name contains'Test',而不是appProperties has {key ='X'and value ='Y' };
// String orderBy =name;

//案例3:成功并列出文件
//与案例1类似,但appProperties条件被删除。
// String query =name contains'Test';
// String orderBy =name,createdTime;

//例4:超时
//与情况1类似,但是名称标准被丢弃。
// String query =not appProperties has {key ='X'and value ='Y'};
// String orderBy =name,createdTime;

//案例5:类似于案例1的错误输出
//与案例4类似,但是选择查询被反转
// String query =appProperties has {key ='X'and value ='Y'};
// String orderBy =name ,createdTime;

//案例6:成功并列出文件。
//与情况4类似,但名称按排序顺序丢弃。
// final String query =not appProperties has {key ='X'and value ='Y'};
//最终字符串orderBy =createdTime;

FileList result = mService.files().list()
.setPageSize(10)
.setFields(nextPageToken,files(id,name))
//下面添加了
.setOrderBy(orderBy)
.setQ(query)
//结束添加的代码
.execute();
列表< File> files = result.getFiles();
if(files!= null){
for(File file:files){
fileInfo.add(String.format(%s(%s)\\\

file.getName(),file.getId()));
}
}
return fileInfo;
}


解决方案

回答:

我认为您应该将此报告为Google的错误。我一直在玩它,我不能得到 appProperties 作为 file.list 就像文件资源不包含该字段,所以你会从搜索。即使我的字段设置为*,应该返回文件的所有字段也是如此资源

当您举报时,向他们发送您的示例 apps-api-issues 也链接了这个问题。将您的问题请求链接回此处,我会查看是否可以在Google云端硬盘上找到某人来ping通它。


Update: This issue appears to have been resolved. See the bug tracker report for details.


I am having some difficulty getting a file listing request through the Drive REST API (v3) accomplished without an internal server error (error code 500.) I am trying to use the name and appProperties keys with a call to files().list() in the search criteria with name and createdTime for the sort order. (This is "case 1" in the code below.) The syntax I am using is documented here.

In an attempt to isolate the problem, I have taken the Google Drive API > REST Android Quickstart project found here and made some modifications to the getDataFromApi method as shown in the code block below.

There are six test cases using various combinations of search criteria and sort order fields. Some queries succeed while others fail with server code 500 and one times out. These results are consistent on an emulator running Android 7.0 with API 24. My issue originated with an earlier release.

I am most interested in getting a solution to case 1 and offer the other cases as my attempt to figure out what was going wrong. I would appreciate any assistance or ideas on what I might be doing wrong or what else may be happening.

         private List<String> getDataFromApi() throws IOException {
            // Get a list of up to 10 files.
            List<String> fileInfo = new ArrayList<String>();

/*          Case 1: Crashes with following error:
             500 Internal Server Error
             {
              "code" : 500,
              "errors" : [ {
              "domain" : "global",
              "message" : "Internal Error",
              "reason" : "internalError"
             }],
              "message" : "Internal Error"
             } */
            String query = "name contains 'Test' and not appProperties has {key='X' and value='Y'}";
            String orderBy = "name, createdTime";

//            Case 2: Succeeds and lists files.
//            Like case 1, but "createdTime is dropped in sort order.
//            String query = "name contains 'Test' and not appProperties has {key='X' and value='Y'}";
//            String orderBy = "name";

//            Case 3: Succeeds and lists files.
//            Like case 1, but appProperties criteria is dropped.
//            String query = "name contains 'Test'";
//            String orderBy = "name, createdTime";

//            Case 4: Times out.
//            Like case 1, but the name criteria is dropped.
//            String query = "not appProperties has {key='X' and value='Y'}";
//            String orderBy = "name, createdTime";

//            Case 5: Errors out like case 1.
//            Like case 4, but the selection query is inverted.
//            String query = "appProperties has {key='X' and value='Y'}";
//            String orderBy = "name, createdTime";

//            Case 6: Succeeds and lists files.
//            Like case 4, but name is dropped in sort order.
//            final String query = "not appProperties has {key='X' and value='Y'}";
//            final String orderBy = "createdTime";

            FileList result = mService.files().list()
                    .setPageSize(10)
                    .setFields("nextPageToken, files(id, name)")
                    // following was added
                    .setOrderBy(orderBy)
                    .setQ(query)
                    // end added code
                    .execute();
            List<File> files = result.getFiles();
            if (files != null) {
                for (File file : files) {
                    fileInfo.add(String.format("%s (%s)\n",
                            file.getName(), file.getId()));
                }
            }
            return fileInfo;
        }

解决方案

Major edit of answer:

I think you should report this as an bug to Google. I have been playing with it and I cant get appProperties to return as part of a file.list its like the file resource doesn't contain that field so you get an error from the search. This is true even when I have fields set to * which should return all the fields of a file resource.

When you report it send them your examples apps-api-issues link this question as well. Link your issue request back here and I will see if I can find someone on the Google Drive to ping about it.

这篇关于使用Drive REST API的文件().list()上的内部服务器错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆