Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,446
Community Members
 
Community Events
165
Community Groups

How to enable/associate a newly created group with an app related directory via REST API?

I can create a new group via REST API but can't find any API to enable/associate the newly created group with the application Directory. Currently, this has to be done via the Admin console GUI.

Has anyone found the right API for this?

Thanks

2 answers

1 accepted

see the reply section :-)

Hello Allan,

Please see my answer here (this is a duplicate question as far as I understand it): https://community.atlassian.com/t5/Crowd-questions/Atlassian-CROWD-REST-API-for-quot-Associating-linking-a-Group-to/qaq-p/582495

Thanks Bruno,

It does the trick :-)

Another question, I can't remove a user from a group, it gave me error.

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
X-Embedded-Crowd-Version: Crowd/2.11.0
X-Crowd-User-Management-Version: 1.4
X-ASEN: SEN-L9527447
Set-Cookie: JSESSIONID=7ED6DFD32CFE6B3A68A178A3213EE782; Path=/crowd/; HttpOnly
X-Content-Type-Options: nosniff
Vary: Accept,Accept-Encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 02 Jun 2017 17:26:12 GMT
Connection: close

{"message":"The validated object is null","status-code":500,"stack-trace":"java.lang.NullPointerException: The validated object is null\r\n\tat org.apache.commons.lang3.Validate.notNull(Validate.java:222)\r\n\tat org.apache.commons.lang3.Validate.notNull(Validate.java:203)\r\n\tat com.atlassian.crowd.manager.application.AliasManagerImpl.findUsernameByAlias(AliasManagerImpl.java:41)\r\n\tat sun.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat

...

Here is the RestApi snippet

curl -X DELETE -ik -u $app:$passwd -H "Content-Type: application/json" -H "Accept: application/json" https://$crowdServer/crowd/rest/usermanagement/1/group/user/direct?groupname=$name&username=$user

Appreciate your input on this.

Thanks,

Allan

 

 

The resource URI should be

/rest/usermanagement/1/user/group/direct

instead of

/rest/usermanagement/1/group/user/direct

;-)

https://docs.atlassian.com/atlassian-crowd/latest/REST/#usermanagement/1/user-removeUserFromGroup

Thanks for quick response, still no luck, something weird with the error message it said groupName can't be empty.

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
X-Embedded-Crowd-Version: Crowd/2.11.0
X-Crowd-User-Management-Version: 1.4
X-ASEN: SEN-L9527447
Set-Cookie: JSESSIONID=AA14A44B09E04478E90B78DD6D12E5C0; Path=/crowd/; HttpOnly
X-Content-Type-Options: nosniff
Vary: Accept,Accept-Encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 02 Jun 2017 18:33:49 GMT
Connection: close

{"message":"groupName cannot be null or empty","status-code":500,"stack-trace":"java.lang.NullPointerException: groupName cannot be null or empty\r\n\tat org.apache.commons.lang3.Validate.notEmpty(Validate.java:395)\r\n\tat

Here is the harcoded groupname and username:

curl -X DELETE -ik -u $app:$passwd -H "Content-Type: application/json" -H "Accept: application/json" https://$crowdServer/crowd/rest/usermanagement/1/user/group/direct?username=dude123&groupname=qa_leads

Worked for me with single quotes around the URL

curl -X DELETE -i -u 'test:********' -H "Content-Type: application/json" -H "Accept: application/json" 'http://localhost:8095/crowd/rest/usermanagement/1/user/group/direct?username=jdoe&groupname=foo'

HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
X-Embedded-Crowd-Version: Crowd/2.12.0
X-Crowd-User-Management-Version: 1.4
X-ASEN: SEN-1268554
Set-Cookie: JSESSIONID=069C5553F7A440C5ED785E56B8D0834F; Path=/crowd/; HttpOnly
X-Content-Type-Options: nosniff
Content-Type: application/json
Date: Fri, 02 Jun 2017 18:50:32 GMT

Thanks Bruno, finally it worked by adding the single quotes around the URL as you suggested.

I have just noticed that a new group that I created using Rest API, was marked as Active = False by default.

How can I change it to Actrive = True?

Thanks,

Allan

Never mind, I have just added the missing "Active" attribute and set it to True.

The suggestion here to link a group with an app works,  https://community.atlassian.com/t5/Crowd-questions/Atlassian-CROWD-REST-API-for-quot-Associating-lin...

However if you have multiple directories that are associated with an app, then the newly created group only linked with the first directory in the order. How to link the new group with the rest of directories?  

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

320 views 0 10
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you