当调用 Google 管理目录 API 编写恢复电子邮件时,我收到响应状态代码 400 BAD REQUEST
When calling Google Admin Directory API to write recovery email, I get response status code 400 BAD REQUEST
这是我的代码:
这是回复:
2020/09/14 12:19:51.425:将 ppsEmailAddress 添加为恢复电子邮件的信息结果:{data=[object Object],finalURL=https://www.googleapis.com/admin/directory/v1/users/ttestaccount@pps.net, headers={Alt-Svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43", Content-Length=357, Content-Type=application/json; charset=UTF-8,Date=Mon,2020 年 9 月 14 日 19:19:51 GMT,Server=ESF,Vary=[Origin, X-Origin, Referer],X-Content-Type-Options=nosniff,X-Frame- Options=SAMEORIGIN, X-XSS-Protection=0}, initialURL=https://www.googleapis.com/admin/directory/v1/users/ttestaccount@pps.net, statusCode=400.0, statusReason=Bad Request}
完整代码:
尝试按照此处的 Google API 参考,尽管我的语法有问题:
https://developers.google.com/admin-sdk/directory/v1/reference/users#resource
提出了类似的请求
这是我请求的格式:
PATCH /admin/directory/v1/users/youremail@joshgoldeneagle.com HTTP/1.1
Host: www.googleapis.com
Content-length: 45
Content-type: application/json
Authorization: Bearer {REPLACE WITH ACCESS TOKEN}
{
recoveryEmail: "yourPatchEmail@joshgoldeneagle.com"
}
确保 callGoogleAPI()
以这种格式发出请求。
参考资料:
https://developers.google.com/admin-sdk/directory/v1/reference/users/patch
这是我的代码:
这是回复:
2020/09/14 12:19:51.425:将 ppsEmailAddress 添加为恢复电子邮件的信息结果:{data=[object Object],finalURL=https://www.googleapis.com/admin/directory/v1/users/ttestaccount@pps.net, headers={Alt-Svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43", Content-Length=357, Content-Type=application/json; charset=UTF-8,Date=Mon,2020 年 9 月 14 日 19:19:51 GMT,Server=ESF,Vary=[Origin, X-Origin, Referer],X-Content-Type-Options=nosniff,X-Frame- Options=SAMEORIGIN, X-XSS-Protection=0}, initialURL=https://www.googleapis.com/admin/directory/v1/users/ttestaccount@pps.net, statusCode=400.0, statusReason=Bad Request}
完整代码:
尝试按照此处的 Google API 参考,尽管我的语法有问题: https://developers.google.com/admin-sdk/directory/v1/reference/users#resource
这是我请求的格式:
PATCH /admin/directory/v1/users/youremail@joshgoldeneagle.com HTTP/1.1
Host: www.googleapis.com
Content-length: 45
Content-type: application/json
Authorization: Bearer {REPLACE WITH ACCESS TOKEN}
{
recoveryEmail: "yourPatchEmail@joshgoldeneagle.com"
}
确保 callGoogleAPI()
以这种格式发出请求。
参考资料: https://developers.google.com/admin-sdk/directory/v1/reference/users/patch