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

List of users in project (REST API)

Is there a way to get a list of all users assigned to a project using the Jira REST API?

I'm aware that I can get a list of roles, but not how to get the users in these roles.

Thanks!

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted

Hi Tobias,

Unfortunately you can not do this with 1 REST call, but only with a sequence of calls. In the following explanation I'm running on localhost and my project had the key ITP:

1) Call the following url: http://localhost:2990/jira/rest/api/2/project/ITP. This will return the following output:

{
self: "http://localhost:2990/jira/rest/api/2/project/ITP",
id: "10100",
key: "ITP",
description: "",
lead: {
self: "http://localhost:2990/jira/rest/api/2/user?username=admin",
key: "admin",
name: "admin",
avatarUrls: {
16x16: "http://localhost:2990/jira/secure/useravatar?size=xsmall&avatarId=10122",
24x24: "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
32x32: "http://localhost:2990/jira/secure/useravatar?size=medium&avatarId=10122",
48x48: "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
},
displayName: "admin",
active: true
},
components: [ ],
...
name: "IntegrationTestProject",
roles: {
Users: "http://localhost:2990/jira/rest/api/2/project/ITP/role/10000",
Administrators: "http://localhost:2990/jira/rest/api/2/project/ITP/role/10002",
Developers: "http://localhost:2990/jira/rest/api/2/project/ITP/role/10001",
Service Desk Customers: "http://localhost:2990/jira/rest/api/2/project/ITP/role/10100"
},
...
}

The most important part are the roles here, because this section gives you an overview of all roles (and persons) in the project. As you can see every field (Users, Developers,...) contains a new REST url. You have to follow all urls.

2) Do a second REST call for every role url. The url for Developers (http://localhost:2990/jira/rest/api/2/project/ITP/role/10001) gives the following result:

{
self: "http://localhost:2990/jira/rest/api/2/project/ITP/role/10001",
name: "Developers",
id: 10001,
description: "A project role that represents developers in a project",
actors: [
{
displayName: "admin",
type: "atlassian-user-role-actor",
name: "admin",
avatarUrl: "/jira/secure/useravatar?size=xsmall&avatarId=10122"
},
{
id: 10201,
displayName: "jira-developers",
type: "atlassian-group-role-actor",
name: "jira-developers",
avatarUrl: "/jira/secure/useravatar?size=xsmall&avatarId=10123"
}
]
}

Here we have 2 types of role members. The 'admin' is of type User and points directly to a user name (which is what you want). The jira-developers refers to another group that contains more then one user. To get all the users here we need a third REST call.

3) Do a third REST call for every user group (http://localhost:2990/jira/rest/api/2/group?groupname=jira-developers&expand=users). The expand parameter makes sure that user information is also included in the response:

{
name: "jira-developers",
self: "http://localhost:2990/jira/rest/api/2/group?groupname=jira-developers",
users: {
size: 1,
items: [
{
self: "http://localhost:2990/jira/rest/api/2/user?username=admin",
name: "admin",
emailAddress: "admin@example.com",
avatarUrls: {
16x16: "http://localhost:2990/jira/secure/useravatar?size=xsmall&avatarId=10122",
24x24: "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
32x32: "http://localhost:2990/jira/secure/useravatar?size=medium&avatarId=10122",
48x48: "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
},
displayName: "admin",
active: true
}
],
max-results: 50,
start-index: 0,
end-index: 0
},
expand: "users"
}

When you do this recursively for every project role and group, you should get all the info you need.

Hope this helps?!

Helps. Thanks a lot!

Hello Benji Mommen, Thank you for your answer, I followed your guide and when I call (2nd step) https://insight.fsoft.com.vn/jira/rest/api/2/project/11419/role/10200 (I use Postman extension on Chrome, GET, Authorization header) I got: { "errorMessages": [ "You cannot edit the configuration of this project." ], "errors": {} } Does my account need some special permission to do this? I don't intend to EDIT anything, I just want to read via a GET request. Could you help me please? Thank you very much!

This anwer must be coming with HTTP status 404 according to rest api documentation: https://docs.atlassian.com/jira/REST/6.3.10/#d2e2420 I'm getting 401 on my 6.3.10 instance though. Such response comes for me for those those projects which I don't have in the Administration -> Projects section (http://jira_host/secure/project/ViewProjects.jspa)

Hi I am getting the same error when I am doing the GET request from a normal user. Is there any workaround so that can get the user role ?

Thanks. Nice. But this takes hours having over 100 projects and more than 10 roles. Hope there wil be more specific rest functions for this in the future.

Sorry for the late answer!
We had the same issue and wrote a plugin which extends the REST-API of Jira. You can specifiy a user and get the users projects and the permissions and roles assigned to the projects. You can also filter for specific permissions.
The plugin can be found here:
https://marketplace.atlassian.com/plugins/de.materna.jira.plugins.userProjectRest
For further information take a look in the dokumentation assigned to the plugin.

Hi Benji,

I tried your solution...

In step 3 when you call jira API to get the users members of 'jira-developers' group you  will get all users of that group for all projects.

Is there a way you can filter the members of 'jira-developers' by project?

Thanks

hi Safwan,

 

Any solution to your query? 

Hey everyone! I was looking for the same thing and I found this endpoint Find users assignable to projects. I don't know when they encorporated this one to the documentation, but that's all I needed ;D And there's another one that Finds users assignable to issues , which is pretty useful

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Community showcase
Published in Confluence

2019: All Wrap(ped) Up Like a Present

Hindsight might be 2020 but looking back, a lot of cool new features rolled out in 2019. From new collaboration and organizational powers to fresh templates and handy integrations, it’s been quite th...

245 views 0 7
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