Forums

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

.jsonEncode doesn't handle special characters such as < properly

Ano Niempje
April 2, 2025

Hello,

I have a Jira Automation with a POST webhook call to the Confluence API. The body of the post call is something like this:


{{#issues}}

<p>

{{#comments}}

{{body.jsonEncode}}

{{/}}

</p>

 

{{/}}

 

I had an issue where multiline comments would break the call (bad request) so I added jsonEncode to {{body}} which worked, but now when someone is using a special character like < it breaks the call again. 

How do I handle characters like < > " ' & 

 

So that my calls don't break? Thanks!

2 answers

1 accepted

1 vote
Answer accepted
Florian Bonniec
Community Champion
April 2, 2025

Hi @Ano Niempje 

 

Yes <> are not json character but html characters. You could replace them using remove of replace function.

Automation smart values - text fields | Cloud automation Cloud | Atlassian Support

 

You could also try to use the htmlEncode fucntion on your smartvalue.

 

Regards

Ano Niempje
April 3, 2025

Thanks I fixed it by changing this:

  • {{body.jsonEncode}}

To this:

  • {{#jsonEncode}}{{#htmlEncode}}{{body}}{{/htmlEncode}}{{/jsonEncode}}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events