Trying to get list of all users through rest

Ankit kharola January 27, 2025

 

 

I am trying to get a list of users in jira i am using the api 

 

/rest/api/3/users/search  but it doesnt return a total that is the total number of users  and it also has a maxCount of 50 so how do we get a list of all the users in jira if we want to?

2 answers

0 votes
Vishal Biyani
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.
January 27, 2025

@Ankit kharola 

You need to loop through till you get 0 count for users. 

Assuming you are using python

payload = {'startAt': 0, 'maxResults': 1000}

while True:
call the api end point
Get number of users returned.
if number of users == 1000:
payload['startAt'] += 1000
else:
break


hope this helps

Ankit kharola January 27, 2025

 

@Vishal Biyani hello sir  will there be a case where number of users are more than the the number i set in maxresuts? because when we are fetching issues we get a total so we can run a while loop on that as we now the total numbr of issues but here i am confused about that

Vishal Biyani
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.
January 27, 2025

@Ankit kharola 

use this end point, with startAt=0 and maxResults=1000

https://your-domain.atlassian.net//rest/api/3/users?startAt=0&maxResults=1000

Say you have 1500 users. 

in the first call when response.json() length is calculated it will return 1000.

2nd call will be

https://your-domain.atlassian.net//rest/api/3/users?startAt=1000&maxResults=1000

this will give the array length at 500 and this will be termination condition for the while loop.

0 votes
Fazila Ashraf
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, 2025
Ankit kharola January 27, 2025

hello @Fazila Ashraf  i did look at the endpoint but the doubt i have is the endpoint you mentioned  Returns a paginated list of the users specified by one or more account IDs. but i was looking to fetch all the users. and its not returning the total number of users like we get when we are fetching issues. my doubt was when i am getting all users we dont get a total field there so how would we fetch all the users that are there?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events