joshgoldeneagle
joshgoldeneagle

Reputation: 4646

When calling Google Admin Directory API to write recovery email, I get response status code 400 BAD REQUEST

Here is my code:

callGoogleAPi screen capture

Here is the response:

2020/09/14 12:19:51.425: INFO Results for adding ppsEmailAddress as recovery email: {data=[object Object], finalURL=https://www.googleapis.com/admin/directory/v1/users/[email protected], 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, 14 Sep 2020 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/[email protected], statusCode=400.0, statusReason=Bad Request}

Full code: enter image description here

Trying to follow the Google API reference here, though something wrong with my syntax: https://developers.google.com/admin-sdk/directory/v1/reference/users#resource

Upvotes: 0

Views: 373

Answers (1)

iansedano
iansedano

Reputation: 6481

I made a similar request using the Google OAuth Playground

This was the format of my request:

PATCH /admin/directory/v1/users/[email protected] HTTP/1.1
Host: www.googleapis.com
Content-length: 45
Content-type: application/json
Authorization: Bearer {REPLACE WITH ACCESS TOKEN}
{
recoveryEmail: "[email protected]"
}

Ensure that callGoogleAPI() makes a request in this format.

References: https://developers.google.com/admin-sdk/directory/v1/reference/users/patch

Upvotes: 0

Related Questions