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}}{{/}}
Datum | Gebruiker | Commentaar |
---|---|---|
{{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?
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
Thanks Bill! I applied the inline version of the json encode on the body of the comment like so: {{body.jsonEncode}} and that worked!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.