3
votes

I am trying to use JIRA REST API[1] to list all the groups in JIRA. I am currently using JIRA version 6.01 .

I tried /rest/api/2/groups/picker[2] in JIRA REST API 6.01 but could not find a way to specify the parameter "query" as the way I need.

If I use a whole group name in parameter "query", I receive the correct group like this.

Request 1:

GET /jira/rest/api/2/groups/picker?query=jira-users

Response 1

{
   "header": "Showing 1 of 1 matching groups",
   "total": 1,
   "groups": [   {
      "name": "jira-users",
      "html": "<b>jira-users<\/b>"
   }]
}

But if I use a part of the group name in "query" parameter, it does not give expected results.

Request 2

GET /jira/rest/api/2/groups/picker?query=j

According to the method spec [2] I hope to receive all groups that name contains "j" but I do not receive any result.

Response 2

{
   "header": "Showing 0 of 0 matching groups",
   "total": 0,
   "groups": []   
}

Can anyone please let me know the right way to give parameters?

Thank you

[1] https://developer.atlassian.com/static/rest/jira/6.0.1.html

[2] https://developer.atlassian.com/static/rest/jira/6.0.1.html#id150432

1
This REST resource is really just sugar over the regular display groups page in JIRA, even including the HTML text about the number of groups returned. It is limited in the number of groups it will return as well. Sometimes if you have a user who is in all the groups you can use /rest/api/2/user with expand=usersmdoar
@mdoar:Thanks for replying and the suggestion. Other than using an API, is it a good way to get groups using a normal HTTP request?Malintha

1 Answers

5
votes

We're using JIRA 6.0.7 and can do:

/rest/api/2/groups/picker?maxResults=10000

Which will show you all groups up to a max of 10000 results. The the response is important part as it shows the total number of groups, this may require you to adjust the maxResults query parameter that you pass to it if you have too small of a value to show all results:

{
    "header":"Showing 5014 of 5014 matching groups",
    "total":5014,
    "groups":{
        ...
    }
}

If you omit the maxResults it just returns the first 20 out of 5014. However, for us doing:

/rest/api/2/groups/picker?query=j

Will result in all groups containing the letter j to show up. Maybe it wasn't properly implemented in your version. If you are unable to get the query part working properly, you could try and get all results and then do your own filter by analyzing the name for each group object returned.