我正在尝试将新的父文件夹添加到我的大量Google云端硬盘文件中。我正在使用批处理请求以避免发送太多请求,但是当批处理中添加了多个PATCH请求时,这不起作用。 Google服务器返回502 Bad Gateway
HTTP错误响应。有什么问题或者我该如何解决这个问题?
一般:
Remote Address:216.58.196.138:443
Request URL:https://content.googleapis.com/batch
Request Method:POST
Status Code:502 OK
回复标题:
alt-svc:quic=":443"; ma=604800; v="30,29,28,27,26,25"
alternate-protocol:443:quic,p=1
content-length:1613
content-type:text/html; charset=UTF-8
date:Tue, 01 Dec 2015 06:18:36 GMT
server:GFE/2.0
status:502
请求标题:
:authority:content.googleapis.com
:method:POST
:path:/batch
:scheme:https
accept:*/*
accept-encoding:gzip, deflate
accept-language:ru,en-US;q=0.8,en;q=0.6,de;q=0.4,pt;q=0.2,uk;q=0.2,it;q=0.2
authorization:Bearer ya29.PQI-rcaU2_Pd7tq3XufXVWPfje4ioMzBLhvKOieYuFgs2MnxTyQvtJ0QDR7EiWnN5SOPlGo
content-length:2291
content-type:multipart/mixed; boundary=batch691088898561756483
dnt:1
origin:https://content.googleapis.com
referer:https://content.googleapis.com/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.Dm6zFqHZO9M.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Ft%3Dzcms%2Frs%3DAGLTcCPQ-9iC9Y-vGIOJ-RoQCZkFL66QXw
user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
x-chrome-uma-enabled:1
x-client-data:CKW2yQEIqbbJAQjEtskBCPCIygEI/ZXKAQi8mMoB
x-clientdetails:appVersion=5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36&platform=MacIntel&userAgent=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36
x-goog-encode-response-if-executable:base64
x-javascript-user-agent:google-api-javascript-client/1.1.0-beta
x-origin:http://app.local
x-referer:http://app.local
请求有效负载:
--batch691088898561756483
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: <0B28tlN6SgYRacHVwdEQ5b1RtZmc>
PATCH /drive/v2/files/0B28tlN6SgYRacHVwdEQ5b1RtZmc?addParents=0B28tlN6SgYRaS2syM1VGWjllMnc
X-JavaScript-User-Agent: google-api-javascript-client/0.1
Authorization: Bearer ya29.PQI-rcaU2_Pd7tq3XufXVWPfje4ioMzBLhvKOieYuFgs2MnxTyQvtJ0QDR7EiWnN5SOPlGo
X-ClientDetails: appVersion=5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36&platform=MacIntel&userAgent=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36
--batch691088898561756483
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: <0B28tlN6SgYRadVFRV0lRQW1kVlE>
PATCH /drive/v2/files/0B28tlN6SgYRadVFRV0lRQW1kVlE?addParents=0B28tlN6SgYRaS2syM1VGWjllMnc
X-JavaScript-User-Agent: google-api-javascript-client/0.1
Authorization: Bearer ya29.PQI-rcaU2_Pd7tq3XufXVWPfje4ioMzBLhvKOieYuFgs2MnxTyQvtJ0QDR7EiWnN5SOPlGo
X-ClientDetails: appVersion=5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36&platform=MacIntel&userAgent=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36
--batch691088898561756483
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: <0B28tlN6SgYRaLW1qYmxrZUV2S0E>
PATCH /drive/v2/files/0B28tlN6SgYRaLW1qYmxrZUV2S0E?addParents=0B28tlN6SgYRaS2syM1VGWjllMnc
X-JavaScript-User-Agent: google-api-javascript-client/0.1
Authorization: Bearer ya29.PQI-rcaU2_Pd7tq3XufXVWPfje4ioMzBLhvKOieYuFgs2MnxTyQvtJ0QDR7EiWnN5SOPlGo
X-ClientDetails: appVersion=5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36&platform=MacIntel&userAgent=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_10_3)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F46.0.2490.86%20Safari%2F537.36
--batch691088898561756483--
答案 0 :(得分:1)
尝试将网址更改为https://www.googleapis.com/batch
而不是https://content.googleapis.com/batch
使用您的确切请求和数据,但更改URL我收到了200,每个请求都有一个身份验证错误,正如旧令牌所期望的那样。
HTTP/1.1 200 OK
Vary: Origin
Vary: X-Origin
Content-Type: multipart/mixed; boundary=batch_NP9EsgqJk5k_AAFjWZ0MHaM
Date: Thu, 03 Dec 2015 13:52:18 GMT
Expires: Thu, 03 Dec 2015 13:52:18 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=1
Alt-Svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"
Content-Length: 2027
--batch_NP9EsgqJk5k_AAFjWZ0MHaM
Content-Type: application/http
Content-ID: <response-0B28tlN6SgYRacHVwdEQ5b1RtZmc>
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
Content-Type: application/json; charset=UTF-8
Date: Thu, 03 Dec 2015 13:52:18 GMT
Expires: Thu, 03 Dec 2015 13:52:18 GMT
Cache-Control: private, max-age=0
Content-Length: 249
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
--batch_NP9EsgqJk5k_AAFjWZ0MHaM
Content-Type: application/http
Content-ID: <response-0B28tlN6SgYRadVFRV0lRQW1kVlE>
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
Content-Type: application/json; charset=UTF-8
Date: Thu, 03 Dec 2015 13:52:18 GMT
Expires: Thu, 03 Dec 2015 13:52:18 GMT
Cache-Control: private, max-age=0
Content-Length: 249
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
--batch_NP9EsgqJk5k_AAFjWZ0MHaM
Content-Type: application/http
Content-ID: <response-0B28tlN6SgYRaLW1qYmxrZUV2S0E>
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
Content-Type: application/json; charset=UTF-8
Date: Thu, 03 Dec 2015 13:52:18 GMT
Expires: Thu, 03 Dec 2015 13:52:18 GMT
Cache-Control: private, max-age=0
Content-Length: 249
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
--batch_NP9EsgqJk5k_AAFjWZ0MHaM--
答案 1 :(得分:0)
Google的批处理API记录很少。以下是一些尝试的想法:
您可能正在使用错误的端点(https://content.googleapis.com/batch
而不是https://www.googleapis.com/batch
),正如 Brian 已经建议的那样。我从经验中知道,即使您在每个批处理请求中提供了正确的Host:
标头,也无法将不同主机名的请求一起批处理。
您似乎是从Chrome浏览器提交批量请求,并且正在使用SPDY或HTTP / 2提交请求。如果使用curl
之类的命令行工具来代替使用HTTP / 1.1发送请求,会发生什么?
确切的错误回复是什么?看起来您收到了502 Bad Gateway
个text/html
响应正文的回复,这很奇怪。预期的行为是200 OK
响应,其multipart/mixed
响应正文包含您提交的每个请求的application/http
消息。
批次中的PATCH
个请求都没有正文,这可能是一个问题。由于您要做的就是为每个文件添加一个新的父文件夹,如果您尝试在批处理中发出POST https://www.googleapis.com/drive/v2/files/{fileId}/parents
请求会怎样?
如果您正在寻求Google的回复,可以尝试在official Google Apps API issue tracker上提交错误。但是,无法保证Google云端硬盘团队会做出响应,而且我经常看到有效和可重现的错误一次几个月仍未得到确认。
答案 2 :(得分:0)
此问题已在Google Drive API v3中解决。批次工作正常。