我正在尝试了解(并最终使其工作)对google group API的批处理请求。
使用Oauth2 Playground我知道如何执行单个请求:
在第 1 步授权的 API 是
https://www.googleapis.com/auth/admin.directory.group.member.readonly
https://www.googleapis.com/ auth/admin.directory.group.member
https://www.googleapis.com/auth/admin.directory.group.readonly
https://www.googleapis.com/auth/admin.directory.group
在第 3 步中,我正在发出一个帖子请求:
请求 URI: https : //www.googleapis.com/admin/directory/v1/groups/mytestgroup@domain.ext /members
,正文是:
{
“电子邮件”:“lya@example.com”,
“角色”:“会员”
}
到目前为止一切顺利,但现在我试图在批处理请求中做同样的事情,
我试图按照这里的解释:
https
://developers.google.com/admin-sdk/directory/v1/guides/batch#example
但我不明白一切,所以我去了那里:
https ://developers.google.com/storage/docs/json_api/v1/how-tos/batch
因此,我在第 1 步使用相同的 API,但在第 3 步执行了以下请求:
发帖请求:
https
://www.googleapis.com/batch
具有自定义内容类型:
标头现在是
多部分/混合;boundary="batch_foobarbaz"
并在正文请求中:
--batch_foobarbaz
内容类型:application/http
POST /admin/directory/v1/groups/mytestgroup@domain.ext /members HTTP/1.1内容类型:应用程序/json
内容长度:58
{
“电子邮件”:“liz@example.com”,
“角色”:“成员”
}--batch_foobarbaz--
我也尝试了不同的变体,但我从来没有做出正确的请求,我系统地得到400 error。
有人可以帮我解决这个问题,我不知道我能做些什么来纠正这个问题。
在此先感谢,哈罗德