Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adaptavist ScriptRunner - How to escape html?

Mark Lonergan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 16, 2018

Does anybody know the syntax to escape special html characters in ScriptRunner?

I have user input in the form of "H&S" and the ampersand is killing my REST call so I need to escape it.

I can only find Java examples and it looks like the libraries are not available in ScriptRunner

If I have an "&" in the pageBody the post fails.

// Create a new page
def pageResp = post("/wiki/rest/api/content")
.basicAuth(APIUSERNAME, APIPASSWORD)
.header('Content-Type', 'application/json')
.body([
type: "page",
title: pageTitle,
space: [
key: pageSpace // set the space key
],
// Add page under a parent
ancestors: [
[
type: "page",
id: parentPage, // Parent page
]
],
body: [
storage: [
value: pageBody,
representation: "storage"
]
],
metadata:[
labels: [
[name:"hazard-investigations"],
[name:"uncontrolled"]
]
]
])
.asObject(Map)

Thanks in advance.

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events