【问题标题】:Why do I get an error of Invalid Parent Orgunit Id when I'm inserting in Google G Suit?为什么我在 Google G Suit 中插入时会收到 Invalid Parent Orgunit Id 的错误?
【发布时间】:2018-07-31 11:07:06
【问题描述】:

在 Google G Suit 管理员中插入组织时,我收到 Invalid Parent Orgunit Id 的错误。

我传递了真正的父 orgUnitid,但每次收到此错误响应时仍然如此。

"code": 400, "message": "Invalid Parent Orgunit Id"

  • 这是我的代码。

    在 $client->setSubject() 中我传递了电子邮件地址

    C01sgPOLM1 这是我的客户 ID : 在这里我传递了虚拟客户 ID 以供参考。

    public function addOrgUnits()
    {
    
        $client = new Google_Client();
        $client->useApplicationDefaultCredentials();
        $client->addScope([
            'https://www.googleapis.com/auth/admin.directory.orgunit',
        ]);
    
        $client->setSubject('ABCD);
        $payload = [
            'name' => "demo1"
        ];
        $httpClient = $client->authorize();
    
    
        $response = $httpClient->post('https://www.googleapis.com/admin/directory/v1/customer/C01sgPOLM1/orgunits',
            $payload);
        if ($response->getStatusCode() == 200) {
            $users = json_decode($response->getBody()->getContents(), true);
    
            return $this->successResponse(trans('message.organizationFound'), ['data' => $users]);
        }
    
        return $this->errorResponse();
    }
    

【问题讨论】:

  • 你的代码在哪里?这真的没有帮助。
  • edit 成为主题的问题:包括一个重复问题的Minimal, Complete, and Verifiable example。寻求调试帮助的问题(“为什么这段代码不能按我想要的方式工作?”)必须包括:(1)期望的行为,(2)特定的问题或错误,以及(3)重现它所需的最短代码问题本身。另请参阅:What topics can I ask about here?How to Ask
  • 我编辑了问题

标签: google-api-php-client google-admin-sdk google-workspace google-visualization


【解决方案1】:

我看到的行为与您在 API tester 中的行为相同,这很奇怪,因为根据文档,唯一需要的属性是 name。因此,根据文档,您所做的一切都是正确的。我现在唯一的猜测是 API 的行为方式发生了变化,或者这可能是一个错误。我建议您联系G Suite API support team 并报告此行为。

同时,要使其正常工作,您需要传递 parentOrgUnitIdparentOrgUnitPath。我已经用 parentOrgUnitPath 进行了测试,它确实有效。

$payload = [
    'name' => "demo1",
    'parentOrgUnitPath' => "/"
];

我希望这会有所帮助!

【讨论】:

  • 这里我只传递了您建议的 2 个参数,但仍然收到 400 错误和 Invalid Parent Orgunit Id 消息。
  • @anaya 您可以尝试使用“my_customer”作为 customerId 的值吗?另外,您使用的 parentOrgUnitPath 是什么?
猜你喜欢
  • 1970-01-01
  • 2020-09-24
  • 2015-05-24
  • 1970-01-01
  • 2019-08-20
  • 1970-01-01
  • 2016-04-05
  • 2021-03-01
  • 1970-01-01
相关资源
最近更新 更多