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

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.

5 answers

1 accepted

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"
}

did you tried like this

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

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.

did you tried with out "expand=users"?

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.

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

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.

 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,899 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot