Searching for Project list with member id

GINA November 2, 2017

I always take lots of information and tips for JIRA.

Thank you for everyone :)

 

Actually I'm not developer so my question might be unclealy to give me answer.

 JIRA system interface to another system now using REST API

 1) How to search all projects related in spefic user when we call REST API with ADMIN account. 

2) Could I list up all projects in registered in JIRA system without ADMIN account.

 

I hope you are doing well.

Have a good day.

 

 

2 answers

0 votes
GINA November 2, 2017

-

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2017

Hello,

1. What do you mean by "related to specific user"?

2. You will see only those project which the connected user can see.  Admin user can see all projects that is why he can see all projects via Jira REST API .

GINA November 2, 2017

Thank you for your answer :)

1. It's mean I'd like to search all projects which somone invloved as project member. Now we call REST API with admin account.

I wanna change account from admin to user account.

Could you let me know what is REST_API command(?) to do that? 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2017

Ok. So we need to search for all projects where the required user is a member. I guess what you mean by member is that the user is in a role for the project. There is no single REST function which would let you accomplish that. Instead you need to do several calls to REST API:

1. You get all projects. You can do it by calling GET /rest/api/2/project

2. You need to iterate over received projects and to find all project roles. You can do it by calling GET /rest/api/2/project/{projectIdOrKey}/role

3. You need to iterate over received roles and find all memebers in the roles. You can do it by calling GET /rest/api/2/project/{projectIdOrKey}/role/{id}

4. And that is not all yet:) a group member can be a user or a group. That is why you also have to find all users in the received groups. You can do it by calling GET /rest/api/2/group/member

5. If from step 3 and 4 you received the user you are looking for then it means that it is your project. You collect such project in an array.

But actually membership in a role does not mean that a user have access to the project because permissions are defined in the permission scheme. And if a role is not granted any permission in the permission scheme then users in the role will not have any access to the project. If you want to recieve all projects to which the user has the browse permission then you have to do a different sequence of steps.

1. You get all projects. You can do it by calling GET /rest/api/2/project

2. You iterate over all recieved projects and check if the required user has the browse permission to the project

GET /rest/api/2/user/permission/search?username=username&projectKey=projectKey

3. If the user was returned in step 2 then you pust such project to an array

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2017

Ok. So we need to search for all projects where the required user is a member. I guess what you mean by member is that the user is in a role for the project. There is no single REST function which would let you accomplish that. Instead you need to do several calls to REST API:

1. You get all projects. You can do it by calling GET /rest/api/2/project

2. You need to iterate over received projects and to find all project roles. You can do it by calling GET /rest/api/2/project/{projectIdOrKey}/role

3. You need to iterate over received roles and find all memebers in the roles. You can do it by calling GET /rest/api/2/project/{projectIdOrKey}/role/{id}

4. And that is not all yet:) a group member can be a user or a group. That is why you also have to find all users in the received groups. You can do it by calling GET /rest/api/2/group/member

5. If from step 3 and 4 you received the user you are looking for then it means that it is your project. You collect such project in an array.

But actually membership in a role does not mean that a user have access to the project because permissions are defined in the permission scheme. And if a role is not granted any permission in the permission scheme then users in the role will not have any access to the project. If you want to recieve all projects to which the user has the browse permission then you have to do a different sequence of steps.

1. You get all projects. You can do it by calling GET /rest/api/2/project

2. You iterate over all recieved projects and check if the required user has the browse permission to the project

GET /rest/api/2/user/permission/search?username=username&projectKey=projectKey

3. If the user was returned in step 2 then you pust such project to an array

Suggest an answer

Log in or Sign up to answer