Saving multiple IDs from WebResponse into a single SmartValue

Randy Bayas March 26, 2022

I am wanting to save the ID numbers returned from an API call into a Single Smart Value. I then want to reference each ID in the smartvalue to use in future outgoing web requests for automation.

 

I start by using this

GET: https://<<domain>>.atlassian.net/rest/api/3/dashboard/<<dashboardid>>/gadget

 

Which successfully returns the following response:

 

{
"gadgets": [
{
"id": 13715,
"moduleKey": "com.atlassian.plugins.atlassian-connect-plugin:com.stonikbyte.great.gadgets.plugin__filter-based-formula",
"color": "green",
"position": {
"row": 0,
"column": 0
},
"title": "Story Points Remaining"
},
{
"id": 13716,
"moduleKey": "com.atlassian.plugins.atlassian-connect-plugin:com.stonikbyte.great.gadgets.plugin__filter-based-formula",
"color": "green",
"position": {
"row": 0,
"column": 1
},
"title": "Bugs Remaining"
},
{
"id": 13717,
"moduleKey": "com.atlassian.plugins.atlassian-connect-plugin:com.stonikbyte.great.gadgets.plugin__release-gadget",
"color": "green",
"position": {
"row": 1,
"column": 0
},
"title": "Burndown"
},
{
"id": 14950,
"moduleKey": "com.atlassian.plugins.atlassian-connect-plugin:aptis.plugins.epicSumUp__aptis-esu-dashboard-gadget",
"color": "blue",
"position": {
"row": 2,
"column": 1
},
"title": "Epic Sum Up Filter Results"
},
{
"id": 13718,
"uri": "rest/gadgets/1.0/g/com.atlassian.jira.gadgets:filter-results-gadget/gadgets/filter-results-gadget.xml",
"color": "green",
"position": {
"row": 3,
"column": 0
},
"title": "Filter Results"
},
{
"id": 13719,
"uri": "rest/gadgets/1.0/g/com.atlassian.jira.gadgets:filter-results-gadget/gadgets/filter-results-gadget.xml",
"color": "green",
"position": {
"row": 4,
"column": 0
},
"title": "Filter Results"
},
{
"id": 13714,
"uri": "rest/gadgets/1.0/g/com.atlassian.jira.gadgets:stats-gadget/gadgets/stats-gadget.xml",
"color": "green",
"position": {
"row": 2,
"column": 0
},
"title": "Issue Statistics"
},
{
"id": 13960,
"uri": "rest/gadgets/1.0/g/com.atlassian.jira.gadgets:pie-chart-gadget/gadgets/piechart-gadget.xml",
"color": "blue",
"position": {
"row": 1,
"column": 1
},
"title": "Pie Chart"
}
]
}
I then want to create a single smartvalue that is comprised of only the id numbers returned in the GET, like [13715, 13716, 13717, etc....]
I would then like to reference each of those values individually in an outgoing webrequest url later on in my automation. example...[0] for 13715 or [1] for 13716.
Can you assist me with these steps? Thanks!!

2 answers

1 accepted

0 votes
Answer accepted
Randy Bayas April 1, 2022

I wasn't able to figure out how to grab any of the indexed values of my JsonArray, however, I was able to completely change my method and instead of defining 1 smart value as an array, I grabbed each id and saved it as a variable independently. This was a huge pain but it works....

 

If someone figures out how to reference the value in a jsonArray via a smartvalue method, please let me know!!

 

Thanks :)

0 votes
Randy Bayas March 26, 2022

In my testing I was able to successfully create a smartvalue {{itemIds}} by using the following:

 

{{webResponse.body.gadgets.id.asJsonArray}}

 

which returns:

 

[13715,13716,13717,14950,13718,13719,13714,13960]

 

Now I just need to figure out how to reference each of those values independently with a SmartValue function.. like.

 

{{itemIds.get(0)}}

Eliseu José do Nascimento Pedro October 25, 2022

I'm having the same issue.

 

Any luck? 

Suggest an answer

Log in or Sign up to answer