The CreatorCon Call for Content is officially open! Get started here.

Remove or replace Unicode Characters to send long description to JIRA

Stacy1
Mega Guru

Hello,

I have been successful in creating a JIRA from SNOW to JIRA.  However, if my long description in my incident has more than one line where carriager returns or new lines were used I get an error 400:

"{"errorMessages":["Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: com.atlassian.jira.util.http.request.CapturingRequestWrapper$CapturingInputStream@6a671950; line: 19, column: 34]"]} "

So I need to know if anyone has been able to send a rest message where they either removeUTFCharacters and replace them with characters JIRA understands?  Or do I have to write a RegEx to clean up my long description before sending it?

Thank you in advance,

Stacy

 

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage
Try below in your script short_description.replace(/(\r\n|\n|\r)/gm,", ");

View solution in original post

2 REPLIES 2

Mike Patel
Tera Sage
Try below in your script short_description.replace(/(\r\n|\n|\r)/gm,", ");

Thank you Mike,

Because JIRA requires \n to be converted \\n I updated the regex to be description.replace(/(\r\n|\n|\r)/gm,"\\n"); and it worked perfect.

Thanks again,

Stacy