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

How to get multiple values out of {{webhookResponse.body}} array?

Connor
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.
October 27, 2021

I'm building an automation that triggers when an Insight object is edited, and if 2 specific attributes were edited it will update an attribute of another Insight object.

I need to use the "Send web request" action to make an API call to Insight to pull the objects history, so I can determine what attributes were changed and the previous and new values. This is where I'm running into my problem.

I can use {{webResponse.body}} to look at the object history, and from this community question I figured out I can get specific values from the body by using {{webResponse.body.get(#)}}. E.g. {{webResponse.body.get(0)}} to get the value of the first index.

But is there a way to grab more than 1 value from the array? I.e. How do I grab just the first 2 indexes, or a range of indexes like the 2nd to 5th?

3 answers

2 votes
Will Sargent February 28, 2023

Hi All, Using the .get(#) syntax, I was able to step into a JSON array an grab sub-elements.

{{webresponse.body.incident.custom_field_entries.get(0).custom_field.name}}

Hopefully this helps someone else as this is a real tricky item!

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

Will Sargent February 28, 2023

@Romesh @Connor Hope this helps!

Will Sargent February 28, 2023

You can even nest the gets:

{{webresponse.body.incident.custom_field_entries.get(0).values.get(0).value_option.value}}

Will Sargent February 28, 2023

You can also iterate over the list like this:

{{#webresponse.body.incident.custom_field_entries}}{{custom_field.name}} {{/}}

Where custom_field_entries is an array of objects.

Like # people like this
2 votes
Emre Bodur October 27, 2021

This is what you need: https://support.atlassian.com/jira-software-cloud/docs/use-smart-values-to-access-listed-values/

My advise is to invest some hours into smart value docs with some practice. This will give you the ability to realise new use cases without coding.

0 votes
Romesh November 24, 2022

@Connor I'm trying to do the same thing. Have you managed to get this working? 

Connor
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.
December 1, 2022

Hi @Romesh no unfortunately I never did figure this out. I had to shift my focus to some higher priority items, and never got back around to this. I didn't delete the automation rule I was working on as I do want to revisit this, just haven't gotten to it yet. If I do ever figure this out I'll try and remember to let you know.

Like Romesh likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events