Forums

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

Newline in comment breaks my POST call to create a Confluence page

Ano Niempje March 17, 2025

Hello,

I have a Jira Automation Rule with a webhook. Inside of the webhook I send a POST call to create a Confluence page. The content of the page is populated with comments which come from Jira issues. This works when the comments in the Jira issues are single line. But if someone posted a comment on an issue that is multiline, the call breaks returning error code 400 and the following error message:

 

Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1327]

 

The body of my POST call is as follows:

{"type":"page","title":"Weekrapportage. Week:{{now.weekOfYear}} Jaar: {{now.Year}}","space":{"key":"~myspace"},"ancestors":[{"id":404095077}],"body":{"storage":{"value":"

Deze weekrapportage laat alle comments op issues zien die de afgelopen week zijn gewijzigd! Als er géén wijzigingen in kaartjes zijn doorgebracht dan is deze pagina (nog) leeg!


{{#issues}}

key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution{{key}}

{{#comments}}{{/}}

DatumGebruikerCommentaar
{{created.format("HH:mm:ss dd-MM-yyyy")}}{{author.displayName}}{{body}}


{{/}}","representation":"storage"}}}

 

 

So right now the issue is happening at the {{body}} tag in the table under "Commentaar". After Googling the issue I found the issue (which is a newline breaking the call) and a possible solution by replacing the newline. 

 

So I tried {{body.replace("\n"," ") and also this solution described here:

https://jira.atlassian.com/browse/JSWCLOUD-22517

 

But it doesn't work and the same error still occurs. 

How do I handle multiline comments on jira issues without breaking the call to the Confluence REST API?

2 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2025

Hi @Ano Niempje -- Welcome to the Atlassian Community!

I recommend first storing that page's body value in a create variable and adding the JSON encoding function to the end to help create the message.  Then use the variable in the Send Web Request action for the body.

Here are the documentation pages for those features:

Kind regards,
Bill

Ano Niempje March 18, 2025

Thanks Bill! I applied the inline version of the json encode on the body of the comment like so: {{body.jsonEncode}} and that worked!

Like Bill Sheboy likes this
0 votes
Ano Niempje March 17, 2025

One thing to add, I tried adding a mail action and when I used {{body.replace("\n"," ") the mail showed me the multiline as one line so syntax wise it seems to work. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events