Sushant Singh
Sushant Singh

Reputation: 31

how to get all users of a project in JIRA throught rest api

I'm trying to get all the users which are there in a project, I went throught this API https://docs.atlassian.com/software/jira/docs/api/REST/7.9.2/#api/2/user-findAssignableUsers, but idk why I'm getting {"errorMessages":["Internal server error"],"errors":{}}.

I also followed this article https://community.atlassian.com/t5/Answers-Developer-Questions/List-of-users-in-project-REST-API/qaq-p/536820 but I'm getting 401 unauthorised, as I don't have admin rights, I can't use the plugin mentioned in the above article. I'm stuck :( . I'll be thankful if anyone can help me. Thanks.

Upvotes: 3

Views: 8526

Answers (2)

Oumerzoug Haitham
Oumerzoug Haitham

Reputation: 45

This is how you can get all project memebers (users) :

https://{YourCompanyName}.atlassian.net/rest/api/3/user/assignable/search?project={JiraIdProject OR JiraProjectKey}

Upvotes: 1

Vishal Kharde
Vishal Kharde

Reputation: 1727

First of all as Mech suggested, you will need to have admin access to the project to get required details. REST API uses exactly the same permissions as that of the normal JIRA UI.

If you want to fetch all the users(including different project roles) who have access to the respective project, then you need a chain of Jira REST Api calls as below,

  1. Using this api to fetch all the available roles for a project,

    GET /rest/api/2/project/{projectIdOrKey}/role

You will get some response like,

{
    "Administrators": "http://www.example.com/jira/rest/api/2/project/MKY/role/10002",
    "Users": "http://www.example.com/jira/rest/api/2/project/MKY/role/10001",
    "Developers": "http://www.example.com/jira/rest/api/2/project/MKY/role/10000"
}
  1. Then for each of the project roles(fetched in the first step), call the below jira rest api to give the respective list of users by passing the role id and project key,

    GET /rest/api/2/project/{projectIdOrKey}/role/{id}

Upvotes: 5

Related Questions