gpt4 book ai didi

google-drive-api - Google Drive Files.list : 500 error

转载 作者:行者123 更新时间:2023-12-04 05:04:11 26 4
gpt4 key购买 nike

对于我们的应用程序,我们使用具有 2 条腿授权的 Google Drive SDK。
我们使用 Drive SDK 已经很长时间了,但今天我们遇到了 Files.list API ( https://developers.google.com/drive/v2/reference/files/list ) 的新问题。对于来自不同域的某些用户,我们收到以下错误:

{ "error": { "code": 500, "message": null } }



Drive SDK 一切正常吗?这个错误是什么意思?

最佳答案

我建议阅读此 post这帮助我使用 Android 配置和连接到 Google Drive

编辑:

我有同样的 500 错误服务器,为了避免这个错误谷歌推荐 Exponential backoff 据他们说:

Exponential backoff is a standard error handling strategy for network applications in which the client periodically retries a failed request over an increasing amount of time. If a high volume of requests or heavy network traffic causes the server to return errors, exponential backoff may be a good strategy for handling those errors. Conversely, it is not a relevant strategy for dealing with errors unrelated to rate-limiting, network volume or response times, such as invalid authorization credentials or file not found errors.

Used properly, exponential backoff increases the efficiency of bandwidth usage, reduces the number of requests required to get a successful response, and maximizes the throughput of requests in concurrent environments.



示例:

安卓代码:
FileList files = null;

for (int n = 0; n < 5; ++n) {

try {
setStatus("trying n = " + n);
files = service.files()
.list()
.setMaxResults(1)
.setQ("mimeType = 'application/vnd.google-apps.folder' and title = 'folder_title'")
.execute();
}
catch (GoogleJsonResponseException e)
{
if (e.getDetails().getCode() == 500) {
try {
Thread.sleep((1 << n) * 1000 + randomGenerator.nextInt(1001));
setStatus("sleep() n = " + n);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
setStatus("InterruptedException n = " + n + " " + e1.getMessage());
e1.printStackTrace();
}
}
}

}

我已经测试了这段代码,在最后一次尝试中它成功连接

Google 建议对 4xx 和 5xx 服务器使用指数退避 error

4xx server错误主要是认证问题

关于google-drive-api - Google Drive Files.list : 500 error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15685335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com