0

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("abc@mydomain.com").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

  • Try to create another user by using [Users: insert - try it](https://developers.google.com/admin-sdk/directory/v1/reference/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](https://developers.google.com/admin-sdk/directory/v1/reference/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 Oct 07 '16 at 14:42

1 Answers1

0

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.

Sayali
  • 356
  • 1
  • 2
  • 13
  • I do not view these properties through the Google Admin Console, just as you mentioned, I'm using Google's Try It to perform this GET when I created a user account , I can't see any Optional Property name or value. Is there anyone who can tell me Optional Property can be created in programming or not? – marie49673 Oct 07 '16 at 02:55
  • Yes, they can be. Check if you are setting the properties in the format expected. – Sayali Oct 31 '16 at 20:07