Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Allan Margono May 26, 2017

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

0 votes
Answer accepted
Allan Margono June 2, 2017

see the reply section :-)

0 votes
Bruno Vincent
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
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

Allan Margono June 2, 2017

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 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

Allan Margono June 2, 2017

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 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

Allan Margono June 2, 2017

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

Allan Margono June 5, 2017

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

Allan Margono June 5, 2017

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

Allan Margono June 6, 2017

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
AUG Leaders

Atlassian Community Events