JIRA API to get roles by User

Loganayaki December 15, 2022

HI Team,

I am consuming JIRA Rest API V2. In that i want to fetch all the roles by pasisng user name/id.

GET /rest/api/2/user -> this method is not fetching the roles.

Could you help to get the correct api that will return all roles based on user.?

 

Thanks,

Loganayaki

1 answer

0 votes
David Bakkers
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.
December 15, 2022

Hello @Loganayaki 

You cannot get project roles based on a user, only actors (users) based on a project role, which is done via the Get project role actors for role endpoint.

Loganayaki December 15, 2022

Hi @David Bakkers ,

Thanks for your quick response. is there any way to get user roles by using below api?

GET /rest/api/2/user

It shows application roles in API result. but values are not shown.

userApiresult.png

 

Thanks,

Loganayaki

David Bakkers
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.
December 15, 2022

The values aren't shown, because the applicationRoles element needs to be expanded. When you look at the response from the REST API, that information is provided:

"expand": "groups,applicationRoles"

If you expand the applicationRoles element, you will get all the items within it. In the case you've shown above, there is one (1) item inside the items array.

Review the resulting data and determine for yourself if it does or doesn't satisfy what you consider to be 'roles' for that user.

Good luck on your learning journey

Like Mizuho Kinay likes this

Suggest an answer

Log in or Sign up to answer