Rest EndPoint - How to return HTML as response

Hello Community,

I have written a Rest Endpoint which works perfectly.

When you hit the Rest EndPoint ,<jira base url>/rest/Scriptrunner/...> my code runs and I return JSON.

What I want to do now is I want the Rest Endpoint to re-direct to a different page.

I know its quite easy if you add the following line to the <head> element of the HTML page: 

<meta http-equiv='refresh' content='0; url=http://<jira base url>' />

But I cant figure out how to add that to my Rest Endpoint.

I tried adding it to the response as such:

 return Response.ok("<meta http-equiv='refresh' content='0; url=http://<jira base url>).build()
 

with no luck, it just displayed as a String.

 

Would anyone know how to do return HTML from a REST Endpoint in Jira?

Thank you!

-Roberto

 

Code:

Everything works perfectly except for the Response. I want to know how to Respond to the Rest EndPoint with HTML as oppossed to JSON.

//Includes all the required imports, did not paste them for simplicity
@BaseScript CustomEndpointDelegate delegate

multipleReject(httpMethod: "GET") { MultivaluedMap queryParams, String body, HttpServletRequest request ->

//Grab the extra paths associated inside url /SOEID/IssueKey
def extraPath = getAdditionalPath(request)
def user = extraPath.split('/')[1];
def issueKey = extraPath.split('/')[2];

//Do some calculations that I did not paste.
//I pretty much use the extra parameters and do some validation



//Attempting to return HTML as my response
return Response.ok("<meta http-equiv='refresh' content='0; url=<jira base URL>' />").build()

}  

 

 

1 answer

1 accepted

1 votes
Alexey Matveev Community Champion Jan 04, 2018

Hi @Alexey Matveev,

Crazy, right after posting this I found the same link.

Solved my issue completely!

Thank you!

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,864 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot