Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How do I treat line break in scriptrunner

I have the follow code in scriptrunner that make a update in a external application through API, but when a field have many paragraphs, there are a break line making the json badly formatted. How do I treat this?

There is the code:

def endpointUrl = "${issue.key}"
def http = new HTTPBuilder(endpointUrl)
def msg_update_epico = ""

http.request(PUT, ContentType.JSON) {
def requestContentType2 = ContentType.JSON
request.addHeader("Authorization: Bearer ${token}", "ContentType: application/json")

def commentManager = ComponentAccessor.getCommentManager()

// body = "{ \"status_id\": \"${status_cvv_id.toString()}"

body = """
"status_id": "${status_cvv_id.toString()}",
"name": "${issuesummary}",
"delivery_date": "${devdate_value}",
"username": "${event_username}",
"useremail": "${event_useremail}",
"epic_description": "${issuedescription}",
"Progresso": "${progress.toString()}"

}""""POSTING update epic: ${endpointUrl}")"${body}")
msg_update_epico = JSON.message
//log.debug("Retorno update épico: ${msg_update_epico}")
log.debug("Retorno update épico: Automação executada com sucesso")

  when I updated some epic description there is a sent json:



"status_id": "17437",
"name": "Problemas de Lentidão na Integração.",
"data_delivery": "2022-03-25",
"username": "xxxxxxxxxxxx",
"useremail": "",
"epic_description": "O QUE?
Problemas de Lentidão na Integração selecionados na black friday. Otimização do processo de atualização dos dados.

Realize o acompanhamento da integração de dados para o WM, faça o acompanhamento dos processos com tempo acima do esperado.

Evidênciar estudo de tempos e processos acelerados junto à operação do CD
"Progresso": "0,00%"


Is there any whay to treat this break line? 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Edimara Souza 


I haven't tried it, but could you use the trim method?


"epic_description": "${issuedescription.trim()}",



Hi @Tim Perrault 


Its won't work :(

You could try with replaceAll. Again haven't tried it, but worth a shot.


"epic_description": "${issuedescription.replaceAll("(\r\n)", "")}",
Like Edimara Souza likes this

Thanks @Tim Perrault 


You are an angel! :)

@Edimara SouzaI'm so glad it worked for you! Have a great Day!

Like Edimara Souza likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events