我们使用REST API运行与Gmail同步的服务。自上周三以来,我们的一些(未更改的)Gmail测试已经开始偶尔失败。 原因出现在Gmail REST API端。
一个失败的测试涉及创建标签,创建消息,使用标签标记消息,然后重命名标签。如果测试失败,更改标签名称的POST
请求将返回 404 错误。在第一个 404 之前或之后,该标签或标签列表上的GET
将成功返回相关标签。重试POST
会导致 404 至少持续30秒,即使重试之间间隔为5秒。在尝试POST
之前添加15秒的延迟无济于事。
这是一个已知问题吗?如果是这样,有没有任何已知的解决方法?我们可以提供什么来帮助诊断和解决这个问题?我们正在使用Google-HTTP-Java-Client / 1.22.0客户端库。
这是来自POST成功的请求/响应:
POST https://www.googleapis.com/gmail/v1/users/me/labels/Label_4311
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: pexlabs Google-API-Java-Client Google-HTTP-Java-Client/1.22.0 (gzip)
x-http-method-override: PATCH
Content-Type: application/json; charset=UTF-8
Content-Encoding: gzip
Content-Length: 38
{"name":"mystery"}
HTTP/1.1 204 No Content
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
Server: GSE
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
ETag: "SJIjOPuAzi7meWvLIr4rJgaI0K4/vyGp6PvFo4RvsFtPoIWeCReyIC8"
Vary: X-Origin
Vary: Origin
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Date: Tue, 20 Sep 2016 15:30:51 GMT
这是来自POST失败的请求/响应:
POST https://www.googleapis.com/gmail/v1/users/me/labels/Label_4317
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: pexlabs Google-API-Java-Client Google-HTTP-Java-Client/1.22.0 (gzip)
x-http-method-override: PATCH
Content-Type: application/json; charset=UTF-8
Content-Encoding: gzip
Content-Length: 38
{"name":"mystery"}
HTTP/1.1 404 Not Found
X-Frame-Options: SAMEORIGIN
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
Server: ESF
X-XSS-Protection: 1; mode=block
Content-Length: 1596
Date: Tue, 20 Sep 2016 15:44:08 GMT
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/gmail/v1/users/me/labels/Label_4317</code> was not found on this server. <ins>That’s all we know.</ins>
查看几次运行,Server
响应标头值在成功和失败之间有所不同(尽管可能是设计)。
答案 0 :(得分:3)
这是一个非常特殊的错误。标签的修补似乎被打破了。我也得到Error 404 (Not Found)!!1
。到底怎么回事?!
同时您可以获取标签数据,然后更新可以更改的字段,只需根据您的喜好更改名称:
请求1
GET https://www.googleapis.com/gmail/v1/users/me/labels/Label_203?access_token={access_token}
回复1
{
"id": "Label_203",
"name": "test1234",
"messageListVisibility": "show",
"labelListVisibility": "labelShow",
"type": "user",
"messagesTotal": 0,
"messagesUnread": 0,
"threadsTotal": 0,
"threadsUnread": 0
}
请求2
PUT https://www.googleapis.com/gmail/v1/users/me/labels/Label_203?access_token={access_token}
{
"id": "Label_203",
"labelListVisibility": "labelShow",
"messageListVisibility": "show",
"name": "test12345"
}
回复2
{
"id": "Label_203",
"name": "test12345",
"messageListVisibility": "show",
"labelListVisibility": "labelShow"
}
由于某些奇怪的原因,API Explorer无法运行。但是,如果您在请求中从POST
更改为PATCH
,则会起作用:
请求强>
PATCH https://www.googleapis.com/gmail/v1/users/me/labels/Label_203?access_token={access_token}
{
"name": "wow123"
}
<强>响应强>
{
"id": "Label_203",
"name": "wow123",
"messageListVisibility": "show",
"labelListVisibility": "labelShow",
"type": "user",
"messagesTotal": 0,
"messagesUnread": 0,
"threadsTotal": 0,
"threadsUnread": 0
}