Forums

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

webResponse body, iterating over multiple responses

Matthew Berzinskas
Contributor
April 23, 2025

I have a project that receives data from an external widget, including a reporter's email address.

I've successfully extracted the email and can look up the corresponding user in my Service Desk. However, the user lookup can return multiple accounts with the same email, differentiated by accountType (either 'atlassian' or 'customer').

I need a reliable method to extract the accountId specifically for the account where accountType is 'atlassian'. While the 'atlassian' account often appears as the first element in the web response body, I need a solution that works regardless of the element order. - This is in order to set the reporter field to the correct reporter.

Is it possible to achieve this using advanced branching or another mechanism to iterate through the response body data and filter for the 'atlassian' accountType?

2 answers

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
April 23, 2025

Hi @Matthew Berzinskas 

Where are you performing that endpoint call and search: in an automation rule, external application, etc.?

 

If in an automation rule, you could filter the {{webResponse}} values for the accountType using smart value, list filtering:

{{#webResponse.body.values}}
{{#if(equals(accountType, "atlassian"))}}
{{accountId}}
{{/}}
{{/}}

https://community.atlassian.com/forums/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

 

Kind regards,
Bill

Matthew Berzinskas
Contributor
April 23, 2025

I am working in the automation rule. I will give this a try.

Like Bill Sheboy likes this
Matthew Berzinskas
Contributor
April 24, 2025

Hi @Bill Sheboy - in testing, "values" appears blank, I removed it and just went with the .body, and it seems to work as intended.

 

 

Like Bill Sheboy likes this
Bill Sheboy
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.
April 24, 2025

Well done!

When testing rules that parse a webResponse, it is a good idea to run a test where the entire {{webResponse.body}} is written to the audit log first.  Then compare that to what is expected to decide how / which attributes to access...and even if it can be accessed as JSON or smart values.

1 vote
Marek Bujak April 23, 2025

Hi @Matthew Berzinskas , I assume you're trying to fetch some kind of details from webResponse. In that case you should be able to use smart values for instance to get an element from JSON object. 

  • {{webResponse.body}} returns the response body, if the body is a JSON object then you can access values using dot notation e.g. {{webResponse.body.name}}
Matthew Berzinskas
Contributor
April 23, 2025

Hi @Marek Bujak - yes that is correct, I am querying a user by email address and want to ultimately get webResponse.body.accountId

However, the issue is that for many users, querying by email address produces both their Atlassian account id and customer account id, which causes confusion if they have issues reported from a customer account, so the webResponse ends up being an array with body[0] and body[1].

In my test cases, it seems generally body[0] is correct, but I wanted to see if there was a reliable way to filter the webResponse bodies to the one that also had the accountType:atlassian.

Suggest an answer

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

Atlassian Community Events