Not able to retrieve fields within webresponse using smart values

Dharmesh Patel October 9, 2023

Hi,

I'm trying to use a smart value to extract the value field in the fourth element of an array from a web response, but I haven't been successful. Can someone please help me identify what I'm missing?

So far, I have tried {{webResponse.body.custom_fields.get(3).value}}, {{#webResponse.body.custom_fields}}{{#if(equals(name,"resolution_note"))}}{{value}}{{/}}{{/}} and few other things but no luck.

jira automation.jpg

2 answers

0 votes
Dharmesh Patel October 9, 2023

Thanks Bill for the reply.

Yes, I am try to do this in Jira Automation.

I am making an external API call from Jira Automation and using the API response to set the value of one of Jira custom fields

I can capture the entire response in the log action using {{webResponse.body}} but having hard time parsing the Json.

Any idea how can I convert array into list in Jira Automation?

 

image.png

0 votes
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.
October 9, 2023

Hi @Dharmesh Patel -- Welcome to the Atlassian Community!

Context is important for a question like this...

Are you doing this in an automation for Jira rule?  If so, please post an image of your complete rule, images of any relevant actions, and an image of the audit log details showing the rule execution.

Until we see those...

Have to tried writing the entire web response to the audit log to confirm it matches what you expect in your parsing attempts?

Next...Those square brackets tell me response's custom_fields attribute may contain an array, and not a list.  And so that cannot be parsed with get() until it is converted to a list.

Kind regards,
Bill

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.
October 9, 2023

Please try sticking to one conversation thread; that will help others looking at this question to learn if there are multiple possible answers.  Thanks!

Why are you using a REST API call to set a custom field?  Are you updating issues in another Jira instance / site?

Again, would you please post an image of your entire rule?  The audit log is helpful but it does not show all possible things which happen for a rule execution.

Dharmesh Patel October 9, 2023

I can't paste the rule, have some sensitive info in it.

I need to call an external provider API to fetch some data and then use that data to set the custom field with in Jira. I basically need to map the fields between the two solutions.

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.
October 9, 2023

No worries on seeing the rule.  You may want to review it with a colleague to confirm it works as you planned.

Did you note my comment about arrays versus lists?  That response cannot be parsed as a list and so instead you may need to either:

  • modify your call to the external provider to only return the record needed, and/or
  • use text functions of rules to extract what is needed
  • attempt to split the array into a list, and then parse the fields using text functions

Suggest an answer

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

Atlassian Community Events