Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,414
Community Members
 
Community Events
168
Community Groups

How do I get users list using REST API

How do I get users list using REST API?

I need to get All users in one call

8 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted

thanks for commenting, best option we have found in REST is:

https://servername/rest/api/2/user/search?username=a

Which return all users that has 'a' somewhere, but doing it on the entire ABC is ugly... We couldn't find a way to query for multiple letters....

try using wildcard: username=a*

try using "aeiou" for all names.

https://your-domain.atlassian.com/rest/api/2/user/search?username=&startAt=0&maxResults=10000

 

This is what you want. It searches a blank string in all users and blank string is present in all the strings, so it works fine ;)

@Abhinav Bajpai  This does not work as it only returns 100 results. Using Pagination to change the startAt value does not work either. All calls stop at 100 results whether you use startAt=99 or startAt = 0. 

according to documentation, the param "maxResults" can be set to a maximum of 1.000 .  If the value is higher, as in above example its 10.000, the it defaults to 100.

Im using Jira Cloud, can anybody confirm, how it behaves on Jira Server?

In past it was working with:
`https://servername/rest/api/2/user/search?username=.&startAt=0&maxResults=1000` 
"username = ." (dot)

Does this still work?

@Jens Rosemeier Ohh, thanks for the information, actually I faced the same limit issue and scrolled using startAt but totally forgot about this comment :P

for it in self.projects:
size = 100
initial = 0

'''
JIRA API pushes only 100 results at a time so putting a while
loop to fetch whole data in batch of 100s
'''
while True:
start = initial * size
try:
issues = self.jira.search_issues('project={} and updated > -{}m and updated < 0m'.format(it.id, self.diff),start,size,expand='changelog')
print("Issues of new proj: " + str(it.key))
if len(issues) == 0:
break
initial += 1

#Iterate on all updated issues
for issue in issues:

 

This python code uses the jira api and fetches in batch of 100 till it gets 0 results in response

Hi,

It is possible to get the list all users (may be with in the limit of maximum returnable results). We need to use the search API.

https://servername/rest/api/2/user/search?username=%

The wildcard character to be used for this purpose is "%".

This did not work.

I noticed this now. It did indeed work on Jira Cloud instance just recently it stopped working.

What i noticed (undocumented), on Jira Cloud to get all users without filter, it must be called like:
`https://servername/rest/api/2/user/search?username=

Empty value.

This is different to Jira Server instances.

Like Thomas Pilewicz likes this

As of today this is not possible with REST, please vote *and* comment on https://jira.atlassian.com/browse/JRA-29069-- explaining the need for it. If enough people are explaining the business need for this, Atlassian will fix this. It is not hard to fix, it's much hard to get the required attention for having this scheduled.

thanks for commenting, best option we have found in REST is:

https://servername/rest/api/2/user/search?username=a

Which return all users that has 'a' somewhere, but doing it on the entire ABC is ugly... We couldn't find a way to query for multiple letters....

0 votes
vkharisma Atlassian Team Nov 14, 2012

I don't think the Rest API has this ability. As far as I know you'll have to choose a different way, for example you could use the Soap API to do so as shown in this question JIRA SOAP API : get the list of users. Another way might be querying the DB directly.

0 votes

No REST API returns all users in a single call if you have more than 1000 users. I would recomend the multiprojectsearch api in the document John pointed you to.

0 votes
JohnA Rising Star Nov 12, 2012

Hi Elad,

You didn't actually state which application you wanted to get a list of users from, but hopefully this document will be of some use to you as it explains how to use the API and also documents the APIs of the different Atlassian products: https://developer.atlassian.com/display/REST/REST+API+Developer+Documentation

All the best,
John

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS

Atlassian Community Events