Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

About the REST API:How can I get accountID?

Hi Atlassian Team, 

I‘m developing an service system on JIRA,I need add some users to some groups,the API tells that I should use API“add user to group”,but the parameter——’accountId‘ is required,where should I get it? I’m try to use API“get accountid”, but the parameter——"username" is required, where can I get it?

And I try to use ‘query’,for example:

jira01.jpg

But I still cant get it

02.jpg

Thanks.

2 answers

0 votes
Prince Nyeche Community Leader Feb 04, 2021

Hi @韦哲 

Welcome to community! You will need to find a user first in order to extract an accountId. Better to search all users out and filter the ones you need based on displayname or email_address. You can use the endpoint /rest/api/3/users/search to search for every user on the instance and perform filtering

OR

I have a package called jiraone you could try and see if it simplifies things for you. you can get all users and save to a file, then extract the accountid and use it to add users to groups. For example

from jiraone import LOGIN, USER, endpoint, file_reader

user = "email" password = "token" link = "https://yourinstance.atlassian.net" LOGIN(user=user, password=password, url=link)


def add_user_to_group():
USER.get_all_users(pull="active", user_type="atlassian", file="user_file.csv")
read = file_reader(file_name="user_file.csv")
# the read variable will hold accountId of each user on index 0, you can filter
# by display Name for a particular user as the datatype would be a list.
# some filtering done here ...
group = "Dev Team"
for x in read:
LOGIN.post(endpoint.group_jira_users(group_name=group, account_id=x[0])


This is one of the method you could test out. 

Hi @韦哲,

You can get the user account ID using this REST API. You will need to pass the username with this endpoint.

I hope that this helps.

Thanks,
Moga

Suggest an answer

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

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

335 views 9 7
Read article

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