0
votes

I want to create user account and user's Optional Properties (ex. addresses, emails, externalIds, ims, phones, organizations) using Directory API Users-insert. But when I check the insert result, only 4 property can be see (familyName, givenName, password, primaryEmail),but others field doesn't work, and the request is fine with status code 200.

And I try Users- Update or Patch to Optional Properties, and also the request is fine with status code 200, but i cannot see my changes in my user profile.

What do I need to do can create these Optional properties ?

My current scopes are:

private static final String[] tscopes = { 
                "https://www.googleapis.com/auth/admin.directory.user" ,
                "https://www.googleapis.com/auth/admin.directory.orgunit",
            };

Using Users-insert:

User user = new User();
UserOrganization uorg = new UserOrganization();
UserPhone uphone = new UserPhone();
UserName uname = new UserName();

uname.setFamilyName("A").setGivenName("BC");
uorg.setTitle("Engineer").setCostCenter("CA").setDepartment("IT");
uphone.setValue("00-2345678").setType("work");

user.setName(uname).setPassword("abcd").setPrimaryEmail("[email protected]").setOrganizations(uorg).setPhones(uphone);

Directory.Users.Insert dui = service.users().insert(user);
dui.execute();

getLastResponseHeaders:

{cache-control=[no-cache, no-store, max-age=0, must-revalidate], content-encoding=[gzip], content-type=[application/json; charset=UTF-8], date=[Wed, 05 Oct 2016 10:35:23 GMT], etag=["xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx"], expires=[Mon, 01 Jan 1990 00:00:00 GMT], transfer-encoding=[chunked], alt-svc=[quic=":443"; ma=2592000; v="36,35,34,33,32"], server=[GSE], x-content-type-options=[nosniff], pragma=[no-cache], x-frame-options=[SAMEORIGIN], vary=[X-Origin, Origin], x-xss-protection=[1; mode=block]}

getLastStatusCode: 200

1
Try to create another user by using Users: insert - try it, here you can put all the optional parameters that you want to include in your newly created user like ims, phones, organizations and etc. Then try to get this user with the help of Users: get. To verify the result if the other optional parameters that you place are included with the response. In this way, you can verify if your code is correct or the API just built that way. - KENdi

1 Answers

0
votes

If you are trying to view these properties through the Google Admin Console, not all of them are displayed there.
You can create a user and then perform a GET for that user which will bring in all properties of the user. You can try Google's Try It to perform this GET.