G Suite 用户:列表 api 调用失败,响应为 400:Bad 请求

G Suite Users: list api call fails with response 400:Bad Request

请求如下

GET /admin/directory/v1/users? HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

回复如下

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "badRequest",
                "message": "Bad Request"
            }
        ],
        "code": 400,
        "message": "Bad Request"
    }
}

根据他们的要求,此请求是正确的 documentation. If you try the "Try it!" feature on the left top corner in the documentation page 您仍然会遇到此问题。我的请求有什么问题请帮助。

经过一番努力,我找到了答案。问题出在客户参数上,即使它在您必须提供的文档中被指定为可选参数。以下是成功请求取回我账号下的用户

GET /admin/directory/v1/users?customer=my_customer HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer ya29.a0Adw1xeWNBqbsl1krQ0vdnIlKzWLROC0xe-jW7TvHvljX3M3DAw_fXR5xgy2Msfif2WtdBILEjRDwSIUfC9v-2F1ssV9TQJ-lu-O1yywHUuDn5Eb8oiyyaNkBRUyIVDAuZkH2Q4EbYUCYFJzcVzyFYBIqmeCc0KzNv3Kb-qE2awHulI_Mm1LhyDJqtIPnFnMxngx7QoD0qJsDHgysphGYdg
Content-Type: application/json