Google API为批量请求返回400个BadRequest

我正尝试使用对nodejs的请求将请求发送到GMail API 。 问题是甚至槽我生成相同的查询,在文档中,gmail总是响应400的BadRequest

这些是我的JSONforms的标题

{ 'Content-Type': 'multipart/mixed; boundary=c2db2692-8877-4159-bf02-03e6c5d3ffbf', authorization: 'Bearer MY_TOKEN', 'content-length': 231 } 

正文内容示例

 --c2db2692-8877-4159-bf02-03e6c5d3ffbf Content-Type: application/http Content-ID: <item1:12930812@barnyard.example.com> GET /gmail/v1/users/sneg0k32@gmail.com/messages/14c6c0c43e9bb16b --c2db2692-8877-4159-bf02-03e6c5d3ffbf-- 

任何build议为什么发生这种情况 请求生成额外的几个空格,并以小写字母,但我不知道这是否是问题。

nodejs代码示例

 request({ method: 'POST', uri: 'https://www.googleapis.com/batch', auth: { bearer: key }, headers: { 'Content-Type': 'multipart/mixed' }, multipart: _.map(queries, function(query) { return { 'Content-Type': 'application/http', 'Content-ID': "<item1:12930812@barnyard.example.com>", body: 'GET ' + query } }) }, function(error, response, body) { console.log(response.request.headers) _.map(response.request.body, function(chunk) { console.log(chunk.toString()) }) console.log(body) }) 

UPD:这显然是一个问题,我如何让我的节点调用,通过HTTPTester发送相同的请求,一切工作正常

UPD2 :决定使用学士,但是我还没有想到是什么原因造成这个问题的要求

很难排除这样的问题。 我很可能会说这是下到空间。 我也有类似的问题,因为请求主体由于结构而被视为无效。

大写或小写标题不应该导致问题。

如果有帮助,我已经创build了一个节点模块来创build批量请求: https : //www.npmjs.com/package/batchelor 。 随意使用它。