问题描述
我正在发送以下批处理请求以获取线程:
I'm sending the following batch request for getting threads:
POST /batch HTTP/1.1
Host: www.googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
Content-Type: multipart/mixed; type="application/http"; boundary="737d0154-1999-455c-9886-65d7121a1382"
access_token=accToken"aUser=user
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93fa0>
GET /gmail/v1/users/me/threads/146df2dd11472f07 HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146df14c9a13b5d9 HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146def434891a5b0 HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146def1dbfe6579c HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382
Content-Type: application/http
Content-ID: <0x8d93190>
GET /gmail/v1/users/me/threads/146def155ca0ab2b HTTP/1.1
Host: googleapis.com
Accept-Encoding: gzip
User-Agent: Magin (gzip)
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
--737d0154-1999-455c-9886-65d7121a1382--
但是我从Google服务器收到400个错误的请求作为响应:请求失败:错误的请求(400)
However I get 400 bad request as a response from the Google servers: Request failed: bad request (400)
有什么想法为什么会发生以及如何解决?
Any ideas why this is happening and how I can fix it?
有趣的行为:如果有< = 3个批处理请求,它可以工作,但是如果有更多则不起作用.
interesting behavior: it works if there are <= 3 batched requests but if there are more it doesn't.
推荐答案
我注意到两件事:
(1)第一部分Content-Type之前的空格
(1) the space before the Content-Type on the first part
(2)在POST的末尾(在其自己的行上等)缺少最后一个"--737d0154-1999-455c-9886-65d7121a1382--",请注意后面的-"边界...
(2) missing a final "--737d0154-1999-455c-9886-65d7121a1382--" at the very end of the POST (on it's own line, etc), note the trailing "--" AFTER it the boundary as well...
这篇关于批处理请求-400错误的请求响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!