It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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.

6 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

0 votes
Deleted user Jan 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
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. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

870 views 6 24
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you