Searching for Project list with member id Edited

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 vote
Alexey Matveev Community Champion Nov 02, 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 .

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? 

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 Community Champion Nov 02, 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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

101 views 0 1
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you