Quantcast
Viewing all articles
Browse latest Browse all 280

REST endpoint working fine for in line script but failing when using script editor

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: 

Image may be NSFW.
Clik here to view.
enter image description here

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegateimport groovy.transform.BaseScriptimport com.atlassian.jira.issue.Issue;import javax.ws.rs.core.MultivaluedMapimport javax.ws.rs.core.Responseimport com.atlassian.jira.component.ComponentAccessorimport org.apache.log4j.Loggerimport com.atlassian.jira.project.Projectimport CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks@BaseScript CustomEndpointDelegate delegatecallSubTaskCreator(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:Image may be NSFW.
Clik here to view.
enter image description here

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


Viewing all articles
Browse latest Browse all 280

Trending Articles