Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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 Leaders.
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

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 Leaders.
August 17, 2022 edited

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 Leaders.
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.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events