REST API unjustified user shown in Project

Star July 3, 2018

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 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?

Star July 6, 2018

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 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

Star July 6, 2018

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 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"

Star July 6, 2018

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2018

Sorry @Star

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

Christian Horn May 17, 2022

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