Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trying to create a REST endpoint using script runner

Abyakta Lenka July 8, 2017 edited

i am trying to create a small REST endpoint , please help

here is the small code i am working on. what am i missing ?

trying to add a user to a group

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.user.ApplicationUser

@BaseScript CustomEndpointDelegate delegate

addUserToGroup(httpMethod: "PUT", groups: ["jira-administrators"]) { MultivaluedMap queryParams, String body, HttpServletRequest request ->


GroupManager groupManager = ComponentAccessor.getGroupManager();
try
    {
    groupManager.addUserToGroup(((ApplicationUser) issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ABCD"))).getDirectoryUser() , groupManager.getGroup("Group"))
    } catch (NullPointerException e){ }

 

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Nic Brough -Adaptavist-
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.
July 9, 2017
TAGS
AUG Leaders

Upcoming Apps & Integrations Events