The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Automation - how to asJsonString quote a section?

Martin Cleaver
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 Champions.
August 17, 2022

In some previous steps, I perform a web request to Jira's API. The data I get back is okay.

{{#webhookResponse.body.issues}} | {{key}} | {{fields.summary}} | {{fields.customfield_12930}} | {{/}}

Now I want to provide this to a PUT to update a field:

{
"fields" : {
"description" : {{#webhookResponse.body.issues}} | {{key}} | {{fields.summary}} | {{fields.customfield_12930}} | {{/}}
}
}

 I need to asJSONString quote the {{#webhookResponse.body.issues}}...{{/}} section as wrapping in "" would break if the content includes quotes.

Neither {{#webhookResponse.body.issues.asJsonString}} or {{#webhookResponse.body.issues}}...{{/webhookResponse.body.issues.asJsonString}} works.

So how do I wrap {{#webhookResponse.body.issues}} in asJsonString?

This seems like an easy question... not sure why it's eluding me!

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Martin Cleaver
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 Champions.
August 17, 2022

To answer my own question, I believe it's possible to do this with list.join("\n").asJsonString

Jira smart values - lists | Cloud automation Cloud | Atlassian Support

I'll update when I get a chance.

 

bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 22, 2022

Hi!

Another option might be to use the Create Variable action.  Use that to build up the description text and then in the payload you can just treat it as a plain string e.g. {{newDescription.jsonEncode}}.

Also not sure if you are using the "Additional fields" on the edit issue action or sending a new web request, but if you are using the edit issue action you can just use the built-in description fields instead and it should handle all of that for you.

Cheers,
Brydie

Martin Cleaver
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 Champions.
November 1, 2022

Ah yes, I could just use that. It'd be much simpler.

If only DC was at feature parity for Automation in Cloud.