I need to check to see if a user is in a particular project role using JQuery on the View Issue screen. Is there a way I can do this using the REST API or something similar?
Community moderators have prevented the ability to post new answers.
Actually, you probably can.
/rest/api/2/project/{projectIdOrKey}/role should get you all roles in a project.
/rest/api/2/project/{projectIdOrKey}/role/{id} should get you the actors in the given role.
You can check if the user is part of the output from the second query. I haven't tried it myself but worth checking.
Thanks for the help. This is definitely on the track of what I'm looking for. On the J-Tricks site, I found the following: // Get a list of groups function getGroups(user){ var groups; AJS.$.ajax({ url: "/rest/api/2/user?username="+user+"&expand=groups", type: 'get', dataType: 'json', async: false, success: function(data) { groups = data.groups.items; } }); console.log("Groups : " + groups); return groups; } // Check to see if user is in group function isUserInGroup(user, group){ var groups = getGroups(user); for (i = 0; i < groups.length; i++){ if (groups[i].name == group){ return true; } } return false; } How would I go about modifying these to instead get the roles a user is a member of using the rest urls above?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not with the standard JIRA REST api. You need to create custom JIRA REST plugin for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.