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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

REST API to get all users overall

Hi, I wanted to get all the users through our JIRA and Confluence access using python REST API. Can you please suggest the best way to pull all user details from the platforms? Most vital elements required are the Names and email addresses. 

2 answers

1 accepted

0 votes
Answer accepted
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 07, 2020

@Rishi Jain  Welcome to the community!

You have couple of ways to do this,

  1. Standard rest API, using library of your choice to call that rest (unirest is really nice)
  2. Second way of using python library

Thanks for your response. I could checkout API options where Get All Users needs admin access which I do not have and Bulk Get User needs user IDs to get other user details.

Holding a regular access, is there an API request which can allow me to fetch all user names and email addresses of the users in our network?

Also, if you can please share specific REST API url and method which can help me complete this task?

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 07, 2020

Hi DPK,

 

Thanks for helping out again. The first link request "account id" to be passed - is this the account id of my user account for authentication purpose or the account id of user I need to pull the details for (in the latter, I need all account id's first, how do I get them all?)

 

In the second one, a query needs to be passed, what kind of query it needs? if I need to pull an email list and pass that on, then I do not get an opportunity to find the universe of users from my organization standpoint who have access to the platform.

 

Please advise how to structure any of these to get me all user details without any specific inputs. 

 

Best,

Rishi Jain

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 07, 2020

Oh! my bad I guess linking got mixed up, API I was talking about is,

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?#api-rest-api-3-users-get

It will just need pagination data.

Now, for your knowledge, accountId parameter in API that I gave you previously was id of user of which you want to fetch information.

On second API, query parameter is kind of a search term, that will search into user's email and display name. I used this API to search for all my organization users by giving value of query parameter as 'YOUR_COMPANY_MAIL_DOMAIN', this will give you all use who have email id as, 'EMAIL_NAME'@'COMPANY_MAIL_DOMAIN'

Hi @DPKJ , thanks for your help, the API did work and it is fetching me user accounts, however, I am receiving account IDs and Names of the users. I was hoping if the email id's were also a part of this API output since it is a user information itself. Please advise how to get that aswell through my outputs?

Also, instead of pagination i am using startAt and maxLength to fetch all the users. If there a way also to determine the number of users in total so I can make the maxLength a dynamic value?

 

Please advise and thanks again for all your help.

Update: while getting users using:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-user-email-get

or

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-user-email-bulk-get

 

I am getting a 400 response for email request API calls, the text version of response says "Requestor must be a whitelisted app (not a user)." Please advise how to work around with this?

 

Best Regards

Rishi Jain

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 12, 2020

@Rishi Jain  Oh! I forgot to mention both these API are in experimental tag, so to use them you need to build a app using Atlassian Connect ( https://developer.atlassian.com/cloud/jira/platform/getting-started/ )

There is no work around experimental API as of now.

I would suggest 

GET rest/api/2/user/search?username=.&maxResults=1000&includeInactive=true

Unless your Jira has more than 1000 users that should give you all of the users.  The REST API version 3 is still in Beta and you apparently have to go through some effort to get it working.

Sorry why username is '.' ? Is there documentation about this placeholder?

Like bor_robert likes this
Constantin Noll
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!
Oct 11, 2023

@Mark Thank you for pointing out this option to do the query by using API v2.
This saved my day, as I cannot use API v3 in our environment.

As @Evgen Kyselgov pointed out, it would be nice if the documentation would describe how the username parameter is used to find user and what the '.' means.
See Documentation: Jira 9.11.0 (atlassian.com)

As I have a Jira environment with more than 1000 users, I played around with the startAt parameter, like: 

GET rest/api/2/user/search?username=.&maxResults=1000&includeInactive=true&startAt=1000

This worked, but it threw an "500 Internal Server Error" at the point where startAt + maxResults exceeded the count of users in my environment

In my case: 
/api/2/user/search?username=.&maxResults=1&startAt=3964&includeInactive=true worked

/api/2/user/search?username=.&maxResults=1&startAt=3965&includeInactive=true failed with a 500 Error Code

I hope this information might be useful for someone else.

Suggest an answer

Log in or Sign up to answer