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

This widget could not be displayed.

see the reply section :-)

This widget could not be displayed.
Bruno Vincent Community Champion May 26, 2017

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

 

 

Bruno Vincent Community Champion Jun 02, 2017

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

Bruno Vincent Community Champion Jun 02, 2017

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
Community showcase
Published Feb 27, 2018 in Crowd

The Crowd team is looking for feedback on Server & Data Center customers' identity strategies!

Do you own more than one Server or Data Center product? Do you have challenges provisioning users across your Atlassian products? Are you spending a lot of time integrating each Atlassian product wit...

1,449 views 6 14
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you