How get the list of Jira users through JIRA REST API?

Aniruddha Gayake October 25, 2021

I have a requirement where I want to get the full list of Jira Users in my organization through JIRA Cloud REST APIs. I know I can get details of a user using  /rest/api/3/user endpoint. Also I am aware that we can get multiple users details using /rest/api/3/user/bulk endpoint. But the problem with both these endpoints is that I have to know the userId of user I want to get details of. 

I want to get the list of users same like we get the list of projects using /rest/api/3/project/search endpoint.

Also how can I get the total number of records in user object?

If anybody knows the answer please help.

 

Thanks in advance!

2 answers

0 votes
Mark March 17, 2023

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 above suggested answer uses the REST API version 3 which is still in Beta and you apparently have to go through some effort to get it working.

0 votes
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2021

Hi @Aniruddha Gayake ,

welcome to the community!
As described here you can get a list of all users using

GET /rest/api/3/users

Returns a list of all (active and inactive) users.


Hope this helps!

  • Tessa
Aniruddha Gayake October 25, 2021

Thanks @Tessa Tuteleers  for the response!

But how can I get the total number of users in organization?

eg. Suppose in my organization  there are 100 Jira users, so when I do get users call I would get list of all users. But in the response body or header GET API do not return the total equals 100. I I want that. Is there any way to get total?

In short, I want users API endpoint to return something like thin along with response body:

    {
"maxResults"10,
    "startAt"50,
    "total"72,
    "isLast"false
   
   ""body":{
     ........
     } 
}
Thanks again,
Aniruddha
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 26, 2021

Hi @Aniruddha Gayake , 

the call returns an array of users. 
You can use nearly any programming language you are familiar with to get the size of the array.

  • Tessa 
Aniruddha Gayake October 26, 2021

Hi @Tessa Tuteleers ,

But the my use case is that I want to get the data of all the users by iterating through the paginated user API. So, I must know where the end lies. 

 

Aniruddha

CloudNuro
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!
March 7, 2024

Hi @Tessa Tuteleers 

I am using OAuth 2.0 (3LO) apps to get the code and then using that code to generate the access token. When I am using my access token to hit https://<site-url>/rest/api/3/users/search then it is giving me below error even if the scope I have added based on the documentation. 

{
    "errorMessages": [
        "error.no-permission"
    ],
    "errors": {}
}
Is there any other API to use for OAUTH 2.0?

Suggest an answer

Log in or Sign up to answer