0

I am using a REST endpoint in scriptrunner and here is the code that I am using. The code is working fine when using an in line script but fails when specifying the file in scriptrunner where the code lies as shown in the following picture: 

enter image description here

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate

import groovy.transform.BaseScript

import com.atlassian.jira.issue.Issue;

import javax.ws.rs.core.MultivaluedMap

import javax.ws.rs.core.Response

import com.atlassian.jira.component.ComponentAccessor

import org.apache.log4j.Logger

import com.atlassian.jira.project.Project

import CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks

@BaseScript CustomEndpointDelegate delegate

callSubTaskCreator(httpMethod: "GET", groups: ["jira-users"]) {MultivaluedMap queryParams, String body ->

def log1 = Logger.getLogger("atlassian-jira.log")

log1.warn("MOUNA CAMELIA223"); 

Configuration_CreateMultipleSubtasks conf =new Configuration_CreateMultipleSubtasks()

def MultipleSubtasksHashMap= conf.getSubTaskCreatorHashMap()

String itracCreatemultiplesubtasksProjectCategoriesURL = MultipleSubtasksHashMap["itracCreatemultiplesubtasksProjectCategoriesURL"] as String;

// String itracCreatemultiplesubtasksProjectCategoriesURL= "http://itrac-sustservice.eur.ad.sag:5555/web/subtaskmgr/Login.jsp?iTrac=:1:&reporter=:2:"

log1.warn("MOUNA CAMELIA223 "+itracCreatemultiplesubtasksProjectCategoriesURL); 

 def user = ComponentAccessor.jiraAuthenticationContext?.loggedInUser

  def issueId = queryParams.getFirst("issueId") as Long

  Issue myissue = ComponentAccessor.getIssueManager().getIssueObject(issueId)

  def issueKey = myissue.getKey()

  def itracCreatemultiplesubtasksProjectCategoriesURL2 = itracCreatemultiplesubtasksProjectCategoriesURL.replaceAll(":1:", issueKey)

  def itracCreatemultiplesubtasksProjectCategoriesURL3 = itracCreatemultiplesubtasksProjectCategoriesURL2.replaceAll(":2:", user.getUsername())

  log1.warn("The rest endpoint has been executed by the user " +user)

  Response.temporaryRedirect(URI.create(itracCreatemultiplesubtasksProjectCategoriesURL3)).build()

  

}

This is what I get when I move the code into a file in the script editor. I am normally supposed to click on a button and move to a new page and this is what I get instead: enter image description here

Anyone knows what needs to be changed and how this can be fixed?

0 Answers0