Adding 'n' number of users in a Stash group.

Jewel Francis September 10, 2014

Good afternoon .

I want to add some 100 users into a group in Stash. I am an admin and so I am able to create group and add users. Do I have to add the users individually, or can I add them together, instead of seperately in the group via some plug-in??

 

Regards,

-Jewel

2 answers

1 accepted

1 vote
Answer accepted
ThiagoBomfim
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 11, 2014

Hi Jewel,

To retrieve a list of users from your instance (which is documented here: https://developer.atlassian.com/static/rest/stash/3.3.0/stash-rest.html#idp687024) and use as an input for a parser to obtain the list of users you want to assign to a certain group, please use the curl call below:

$ curl --user admin:admin http://localhost:7990/rest/api/1.0/admin/users

Output:

{"size":3,"limit":25,"isLastPage":true,"values":[{"name":"admin","emailAddress":"user@user.com","id":1,"displayName":"Thiago Bomfim","active":true,"slug":"admin","type":"NORMAL","directoryName":"Stash Internal Directory","mutableDetails":true,"mutableGroups":true,"link":{"url":"/users/admin","rel":"self"},"links":{"self":[{"href":"http://localhost:7990/users/admin"}]}},{"name":"testuser1","emailAddress":"testuser1@user.com","id":2,"displayName":"Test User 1","active":true,"slug":"testuser1","type":"NORMAL","directoryName":"Stash Internal Directory","mutableDetails":true,"mutableGroups":true,"link":{"url":"/users/testuser1","rel":"self"},"links":{"self":[{"href":"http://localhost:7990/users/testuser1"}]}},{"name":"testuser2","emailAddress":"test@user2.com","id":51,"displayName":"Test User 2","active":true,"slug":"testuser2","type":"NORMAL","directoryName":"Stash Internal Directory","mutableDetails":true,"mutableGroups":true,"link":{"url":"/users/testuser2","rel":"self"},"links":{"self":[{"href":"http://localhost:7990/users/testuser2"}]}}],"start":0}

The following curl call works for me and assign the users "testuser1" and "testuser2" to a group called "newtestgroup". This is documented here: https://developer.atlassian.com/static/rest/stash/3.3.0/stash-rest.html#idp759792

$ curl -H "Content-Type:application/json" -H "Accept:application/json" --user admin:admin -X POST -d '{"group": "newtestgroup","users": ["testuser1","testuser2"]}' http://localhost:7990/rest/api/1.0/admin/groups/add-users

I hope that is helpful.

Best regards,
Thiago Bomfim
Atlassian Support - DevTools

 

Jewel Francis September 24, 2014

THank you Thiago. It helps alot. Regards, -Jewel

Arun Ayyampillai January 26, 2017

This works perfectly, is it possible to add users using email id or displayname instead of Users ?

1 vote
Balázs Szakmáry
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.
September 10, 2014

You can do this via the REST API. (You need http://example.com/rest/api/1.0/admin/groups/add-users [POST] )

dericleeyy September 10, 2014

I think there this is mislinked. This should be the right rest point to use https://developer.atlassian.com/static/rest/stash/3.3.0/stash-rest.html#idp687024

Balázs Szakmáry
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.
September 10, 2014

It seems that the numbers after the # change for each session(?) If I navigate to the right place, copy the link, close the tab, paste the link, it takes me to a different place than previously. Anyway. Updated the answer to be more helpful.

Jewel Francis September 10, 2014

Balazs/Deric, Thank you for the update. I am checking it out. Will let you know of the outcome.

Antoine Levy-Lambert October 22, 2014

How does the REST API work to add users when a system is connected to LDAP ? If a stash instance is LDAP enabled it should authenticate the users against LDAP, and find user attributes such as email in LDAP. Is it allowed to add users via REST API without specifying values for email and password ?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events