Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,294,588
Community Members
 
Community Events
165
Community Groups

REST API unjustified user shown in Project

Hello everybody,

i want to list people who have rights in a certrain JIRA Project.

the problem is the REST API shows more user who have authorization, than the JIRA Project itself has.

So the REST API lists more user, than the JIRA project has.

How can i fix this?

thanks in advance

1 answer

0 votes
Nir Haimov Community Leader Jul 04, 2018

Hi,

Can you specify the REST API you tried?

How many people the REST API returned and how many there are actually accoriding to Jira?

With the following API call we get users for the specfied role (in this case e.g. 10301). The most of them are also visible in JIRA itself, but some of the users in the API result do not exist in JIRA, only in the API call. These users used to exist, but are not longer in our company and therefore not longer in JIRA, but somehow the API returns them anyway.

https://JIRA_INSTANZ/rest/api/2/project/PROJECT_KEY/role/10301

Nir Haimov Community Leader Jul 06, 2018

Now i understand your issue :)

Yes, Jira keeps all the users that ever exists (even if they left the company).

Users that left the company (if no one manually delete from Jira) become "not active" in Jira.

So if you want to list only the active people you need to this.

  1. Run "https://JIRA_INSTANZ/rest/api/2/project/PROJECT_KEY/role/10301" to get all the users for the role you want
  2. Take the list of users you got from step 1, and for each one run "https://JIRA_INSTANZ/rest/api/2/user?username=each_user_name"

In step 2 you get the details of the user, and there the API tells you if the user is active or not.

So if he is active, keep it in your list of users, if he is not active remove it from your list.

Finally you will have a list for only all the active users (which is what you wanted)

 

Cheers,

Nir

Thanks for your answer Nir

But this doesnt solve the problem.
When I go to project settings, then in the submenu "Users and roles".
The user who is shown in the REST API is not assigned any role.

We tested it by adding a random user in that role and then remove him again. And it worked fine.
First the user was shown in the REST API then after removing him, he was gone.
That worked fine.
But some users in particular, always stays in the REST API in that project, altough they arent listed in the projects users and roles.

We used to have more JIRA instances, then migrated all to one. Can that be the problem? 

Nir Haimov Community Leader Jul 06, 2018

In my case, there are users in a role and groups in a role.

So maybe the users you don't want to see are hiding in groups?

I don't think the migration is the reason, it doesn't matter where you brought you data from, the API just show you data, that means the users are listed in the Jira (even if they are not supposed to).

 

When are trying to run the REST API i suggested in step 2, all of the users are "active"?

You should see all erelevent users as "not active"

The users are not in Groups. For test purposes we deleted all users/groups from the example role (10301), so that JIRA doesn't show any users or groups for this role now. But the API still shows this one particular user.

The problem why we can't just show the active is, that there can be inactive users which are still related to a role in a project and we want our project leads to remove them. So we have to show the project leads any users which are currently related to the roles in their projects no matter of the users are active or inactive. For almost any inactive users this works fine (so jira normally shows the inactive users under "User and roles".

You can see the problem in the Screenshots belowjira.pngjira2.png

Nir Haimov Community Leader Aug 07, 2018

Sorry @Star

I read you comment few times and did not understand the question / the end goal

Hi,

I have the same problem: one specific user who even doesn't exists in the Jira user database anymore, is returned in the result of a call to the REST API "rest/api/2/project/<project key>/role/10301" but not shown on the "Users and roles" page of the project.

Suggest an answer

Log in or Sign up to answer
TAGS

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