【问题标题】:batch request on google group api with oauth2-playground使用 oauth2-playground 对 google group api 进行批处理请求
【发布时间】:2013-12-22 05:11:43
【问题描述】:

我正在尝试了解(并最终使其工作)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
使用自定义内容类型:
标题现在是
multipart/mixed;边界="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 错误
有人可以帮我解决这个问题,我不知道我能做些什么来纠正这个问题。
在此先感谢,哈罗德

【问题讨论】:

    标签: batch-processing google-groups-api oauth2-playground


    【解决方案1】:

    抱歉,给您带来的不便,我找到了答案。这是我所做的:

    第 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 步中,我正在通过以下方式发出帖子请求:
    https://www.googleapis.com/batch
    具有自定义内容类型:multipart/mixed; boundary="batch_foobarbaz"

    正文请求:

    --batch_foobarbaz
    内容类型:application/http
    内容传输编码:二进制

    POST /admin/directory/v1/groups/mytestgroup@domain.ext/members HTTP/1.1
    内容类型:application/json

    {“电子邮件”:“ldn@example.com”,“角色”:“会员”}
    --batch_foobarbaz--

    这里的重要部分是回车。它们在 Content-Transfer-Encoding: binaryContent-type: application/json

    之后是强制性的

    【讨论】:

      猜你喜欢
      • 2014-12-30
      • 1970-01-01
      • 2011-08-28
      • 2023-02-09
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多