How to list groups and their members in specific directory via RestAPI?
Asked by tiendungitd:

Hi everyone,

How do I get a list of all group and their members in specific directory in crowd? I just want to see a display name of user/group. Also a user status, I want to get only users are activating.

For example

* Group A:
  * User1
  * User2
  * ...
* Group B

I reading Crowd REST API document, but it not mention about Crowd directory, any idea?

Thanks.


Answers:
author: Tarun Sapra
body: Hello [@tiendungitd](/t5/user/viewprofilepage/user-id/662901)

The Crowd REST API is built to be accessed by Applications and thus you can fetch details of users which are part of application-directory mapping i.e. your application must be mapped to the directory whose users you want to fetch. You can also create a dummy application for this purpose.

From the docs

*This set of REST APIs is intended to be used by applications connecting to Crowd.*

*<https://docs.atlassian.com/atlassian-crowd/3.1.3/REST/>*

comments: author: tiendungitd
body: [@Tarun Sapra](/t5/user/viewprofilepage/user-id/781576)

I'm using the command below to fetch user membership

curl -u user:pass <http://localhost:8095/crowd/rest/usermanagement/latest/group/membership>

But it get all users/groups in all Crowd Directories, my expect is only get from one Directory.

Regards

Dung


author: Tarun Sapra
body: That's happening because the username:password you are using belong to an application that is mapped to all directories.


author: tiendungitd
body: Thanks Tarun, now I got your idea. I just added new Generic Application with application url is a current crowd url, now I can get user information in Directory which mapping to the new Application.

Do you know how to list all group?


author: Tarun Sapra
body: Yes, it's easy

please go through the docs here

#### [Get all memberships](https://docs.atlassian.com/atlassian-crowd/3.1.3/REST/?&_ga=2.122908491.112322068.1527667376-769139447.1527667376#usermanagement/1/group-getAllMemberships)`GET /rest/usermanagement/1/group/membership` {#toc-hId-1423568585}

Retrieves full details of all group memberships, with users and nested groups. This resource is optimised for streaming XML responses, and does not support JSON responses.


author: Tarun Sapra
body: [https://docs.atlassian.com/atlassian-crowd/3.1.3/REST/?\&_ga=2.120307784.112322068.1527667376-769139447.1527667376#usermanagement/1/group-getAllMemberships](https://docs.atlassian.com/atlassian-crowd/3.1.3/REST/?&_ga=2.120307784.112322068.1527667376-769139447.1527667376#usermanagement/1/group-getAllMemberships?)


author: manish
body: above given command does work me after i did some changes.

comments: author: manish
body: i need to crowd api to create groups for new user for a new onboarding project


author: Moses Thomas
body: [@tiendungitd](/t5/user/viewprofilepage/user-id/662901)Please check here.

<https://developer.atlassian.com/cloud/jira/platform/rest/?_ga=2.233170077.2066436877.1527418409-887549751.1487154871#api/2/groups-findGroups>

best!

comments: author: Tarun Sapra
body: Hello [@Moses Thomas](/t5/user/viewprofilepage/user-id/1138700)

I think you have mis-read the question as it's about "Crowd Rest API" but the link shared by you is for the "Cloud API"


author: Moses Thomas
body: Yes thanks for the point

[@tiendungitd](/t5/user/viewprofilepage/user-id/662901)Please see link posted by [@Tarun Sapra](/t5/user/viewprofilepage/user-id/781576)