Missed Team ’24? Catch up on announcements here.

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

Add multiples users to group

Marina Vital January 27, 2022

Hello Community!
I need some help with adding multiple users to a group.
When I send the request only one of the users is added.

What am I doing wrong?

 

2022-01-27_20-55.png

1 answer

1 accepted

2 votes
Answer accepted
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2022

Hi @Marina Vital 

I'm afraid this only works for a single user, if you have multiple users, we would need to make multiple calls

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-groups/#api-rest-api-3-group-user-post

Thanks,
Pramodh

Marina Vital January 28, 2022

@Pramodh M 

Thanks!

Like Pramodh M likes this
Charles Chen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 13, 2022

I used the api to add user to the group. it responded nothing and didn't add the user to the group. "get user from group api" works fine. accountId and group id are exported from jira. any idea?

Karl Bolinger
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 12, 2023

Hey, @Marina Vital 

 

I, too, was in a similar predicament. Here's what I was able to do. 

I created a .sh script to add multiple users to a group. 

 

Here's my approach.

⚠️ These are already created users.

  1. Ensure you have admin access and create an API token. It takes a minute for it to process. Come back later. You'll get an email stating that your new API token was created successfully. 
  2. Using Confluence Teams and search by name. Then pull the accountID from the URL.
    1. i.e., https://your-domain.net/wiki/people/612498b165129802006af619ef
    2. accountID = 612498b165129802006af619ef
  3. Export users to CSV. The .csv has a User ID column, which is the accountID. 
  4. Pull the accountIDs you need and paste them into some temp file. 
  5. Get your GroupID
    1. Admin Settings > Groups > Search for group/s > pull GroupID from URL
      1. i.e., https://admin.atlassian.com/s/*/groups/9366eda7-cbde-41f6-8b6d-27fad9219e3c
      2. groupId = 9366eda7-cbde-41f6-8b6d-27fad9219e3c
  6. Now you input your data into the following script/s. 
    1. Your Domain
    2. groupID
    3. accountId/s
    4. your email from which you created your API token & your API token. 

 

#!/bin/bash

# Define the API endpoint and group ID
API_ENDPOINT='https:/your-domain.net/wiki/rest/api/group/userByGroupId?groupId=9366eda7-cbde-41f6-8b6d-27fad9219e3c'

# Define the user account IDs to be added
USER_ACCOUNT_IDS=(
"612498b165129802006af619ef"
"612498b165129802006af619eg"
"612498b165129802006af619eh"
"612498b165129802006af619ei"
"612498b165129802006af619ej"
)

# Loop through the user account IDs and send a curl request for each
for USER_ACCOUNT_ID in "${USER_ACCOUNT_IDS[@]}"; do
curl --request POST \
--url "$API_ENDPOINT" \
--user 'email@example.com:<api_token>' \
--header 'Content-Type: application/json' \
--data "{\"accountId\":\"$USER_ACCOUNT_ID\"}"
done

 

Next, you can check if it was successful by using the following curl command. 

curl --request GET \

  --url 'https://your-domain.atlassian.net/wiki/rest/api/group/member?name={name}' \
  --user 'email@example.com:<api_token>' \
  --header 'Accept: application/json' | jq .

If you need to get the name of your group, run this curl command: 

curl --request GET \ 

  --url 'https://your-domain.atlassian.net/wiki/rest/api/group/by-id?id={id}' \
  --user 'email@example.com:<api_token>' \
  --header 'Accept: application/json' | jq . 
Like Marina Vital likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events