Post

1 follower Follow
0
Avatar

Is there a java API that will return a list of all users in my Orgainization?

I am looking for a java API that will return an iterator such that I can iterate over all users in my organization. The idea will be to get all users and what they all have access to (entitlements, groups, etc.). Is this possible?

Bryan Bible Answered

Please sign in to leave a comment.

5 comments

0
Avatar

Andreas,

Here is the code I user to add it to the API. Everything compiles and I can call the method but I am getting unexpected results. 

public List<User> getOrganizationMembers(int orgId) {

return getResourceFactory().getApiResource("/org/" + orgId + "/member/").get(new GenericType<List<User>>() {});

}

Does this API look correct? Here is a snippet of how I call the API:

 

List<User> memberList = apiFactory.getAPI(OrgAPI.class).getOrganizationMembers(SPOrg_id);

I then iterate over the list and call something simple like 'getMail()' or 'getCreatedOn()' but it returns either 0 or null. The iterator seems to be iterating over the correct number of entries but perhaps the entries arent correct. One thing that concerns me is that if I run the '

Organizations: Get organization members

from the sandbox, it returns the list of all my users but the list looks like it is a list or Profiles and not Users. Can you confirm this? If so then I would need to change the API to return Profile instead of User? Or am I way off here (most likely)

 

Thanks,

 

Bryan

Bryan Bible 0 votes
0
Avatar

Hi Bryan

The list of objects returned is actually not a user, but an object with more information. I will make the API method for this call and put it on GitHub. Then you can copy from there.

The code was otherwise correct.

Christian

Christian Holm 0 votes
0
Avatar

Hi again

I have added the method and released a new version to the maven repositories. It should show up within an hour.

Christian

Christian Holm 0 votes