How to update a user's externalId using Java

核能气质少年 提交于 2019-12-02 10:06:36

When updating external id of user, if the JSON is not set properly, it won't be saved(though it gives 200 response). If you try to send get request on this user, then the updated value is not seen in the response.

Try sending the request using "Oauth Play ground" , where you can build your JSON while sending request.

I tried using {"externalIds":[{"value":"shaggynetwork","type":"network"}]} in "Users.update" request. And in the "Users.get", the response is:

HTTP/1.1 200 OK
Content-type: application/json; charset=UTF-8
{
  "externalIds": [
   {
     "type": "network", 
      "value": "shaggynetwork"
}

],

Steps:

  1. Click on https://developers.google.com/oauthplayground/.

  2. In the step 1, on the left side of "Authorize APIs" in the blank give https://www.googleapis.com/auth/admin.directory.user, then click on "Authorize APIs".

3.In step 2, click on "exchange code for tokens"

  1. In step 3, select HTTP method:PUT, give request URI value:https://www.googleapis.com/admin/directory/v1/users/userKey(giver userkey value).

5.click on "enter request body", build json:

{"externalIds":[{"value":"shaggynetwork","type":"network"}]}

6.CLICK on "send request".

In documentation, its not clear on how to update external id.

Let me know if you need any help on this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!