Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to read all users in a group using REST API in on demand JIRA?

srinivasan radhakrishnan
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.
October 23, 2013

Hi,

I need to read all users in a particular group by using REST API, i have found the below query

https://<companyName>.atlassian.net/rest/api/2/group?groupName=developers&expand=users

The above REST API returns only first 50 users in group , and i can't set the maxResults value in this above REST API

Please share your knowledge.

Thanks in advance.

6 answers

1 accepted

3 votes
Answer accepted
srinivasan radhakrishnan
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.
November 8, 2013

HI All,

I have to read all users in a "Developers" group by using the below format

https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers&amp;expand=users[0:49]

It returns the below JSON

{
    "name": "developers",
    "self": "https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers",
    "users": {
        "size": 150,
        "items": [],
        "max-results": 50,
        "start-index": 0,
        "end-index": 49
    },
    "expand": "users"
}

Then i have parse the return JSON, if the return size is >50 than i have used the below REST API

https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers&amp;expand=users[50:99]

It returns below JSON

{
    "name": "developers",
    "self": "https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers",
    "users": {
        "size": 150,
        "items": [],
        "max-results": 50,
        "start-index": 50,
        "end-index": 99
    },
    "expand": "users"
}

then

https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers&amp;expand=users[100:149]

{
    "name": "developers",
    "self": "https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers",
    "users": {
        "size": 150,
        "items": [],
        "max-results": 50,
        "start-index": 100,
        "end-index": 149
    },
    "expand": "users"
}

2 votes
Ugur Yilmaz
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!
October 21, 2019
rest/api/2/group?groupname=jira-users&expand=users&startAt=0&maxresult=250

This returns only 50 users.

I tried all of them above but result did not change.

Only 50 users were returned. 

0 votes
Deleted user January 10, 2017

It will only get a limited number no matter how large the max-results is set to (something like 250 maximum limit).

The solution to get the whole mess is to read multiple pages, changing the start each time.

I use:
https://<company>/rest/api/latest/group/member?groupname=developersusers&startAt=0&maxresult=250
And then you call it multiple times, changing "startAt" based on how many results you've gotten so far.

Next problem: how do you know when you are done? There is a field in the json "isLast". If this is TRUE you are done and you've got it all.

There is one other little problem you might run into: if you get too many lines from the server in too short a time it hits a limit and stops. The limit is something like 5000 and the time limit is something like 5 minutes. So every 5000 lines, just stop for 5 minutes and it will work.

Note that this is for JIRA; Confluence and Bitbucket also have the paging problem but they solve them differently.

 

0 votes
Radhikaa Bhaskaran
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 31, 2014

Use maxResults parameter in the url :

https://<company>.atlassian.net/rest/api/2/group?maxResults=1000&groupname=developers

I tried the same for obtaining issues of type Task and it worked :

https://<company>.atlassian.net/rest/api/2/search?maxResults=1000&jql=issuetype=Task

Hope this helps.

0 votes
RambanamP
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.
October 23, 2013

did you tried like this

/rest/api/2/group?groupname=developers

srinivasan radhakrishnan
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.
October 23, 2013

Hi Ram,

Thanks for your update, i have tried that request REST API and

- find the numbers of users in this group ( for ex - user count 347 )

Then i expand the users in this api

- https://<companyName>.atlassian.net/rest/api/2/group?groupname=developers?exapnd=users

I am find only 50 users details in the return JSON , because max-Results set as 50 default in On demand JIRA.

How can i increase that maxResults to 400 ?

Thanks in advance.

RambanamP
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.
October 23, 2013

did you tried with out "expand=users"?

srinivasan radhakrishnan
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.
October 23, 2013

Hi Ram

Yes, i have tried with out "expand=users"

https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers

And i got the below JSON

{
    "name": "developers",
    "self": "https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developers",
    "users": {
        "size": 217,
        "items": [],
        "max-results": 50,
        "start-index": 0,
        "end-index": 0
    },
    "expand": "users"
}

I need to read the all users information ( username, dispalyname , address etc., ) in the developers using REST API. How to achieve my goal?

Thanks in advance.

RambanamP
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.
October 23, 2013

can you try like this

https://&lt;company&gt;.atlassian.net/rest/api/2/group?groupname=developersusers&amp;expand=users[0:100]

if it works then you can change to max number

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events