You'll need to import the scripts into the REST area, but yes.
https://scriptrunner.adaptavist.com/4.3.3/jira/rest-endpoints.html lists the things you'll need to look at to make a script provide a REST endpoint.
I am not able to understand the 4th and 5th part
- parameters which are provided to your method body - the body of your method, where you will return a javax.ws.rs.core.Response object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
I am trying a very simple groovy code as rest endpoint.
adding 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){ }
Can you please help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
I am trying to create a small REST endpoint adding user to group
can you please help.
Here is the code i am trying.
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){ }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My guess is that is throwing an error inside the "try". The error should show you what is going wrong (I'd expect a casting error to be the problem, although I've not tried it so that's a very wooly instinctive thing)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.