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 = "https://xxxxxxxx.com.br/v1/integration/jira/epic/${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()}"
}"""
log.info("POSTING update epic: ${endpointUrl}")
log.info("${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": "xxxxxxxxx@xxxxxxx.com.br",
"epic_description": "O QUE?
Problemas de Lentidão na Integração selecionados na black friday. Otimização do processo de atualização dos dados.
COMO?
Realize o acompanhamento da integração de dados para o WM, faça o acompanhamento dos processos com tempo acima do esperado.
CRITÉRIO DE ACEITE
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?
I haven't tried it, but could you use the trim method?
"epic_description": "${issuedescription.trim()}",
Thanks,
Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could try with replaceAll. Again haven't tried it, but worth a shot.
"epic_description": "${issuedescription.replaceAll("(\r\n)", "")}",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Edimara SouzaI'm so glad it worked for you! Have a great Day!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.