Inserting Dynamic Data and Query Chaining

When the first step returns a json object like this

  {
"success":true,
"total":21,
"items":
[
{"id":"762"},
{"id":"763"},
{"id":"764"}
]
}

      

how can i assign a variable id to the first "id" element in the response

I did it like this, but it didn't work

enter image description here

I also tried items.id

, items[0].id

but it didn't work either

+3


source to share


1 answer


To assign a variable to an item in a list, you can use a post-response script .

In this case, something like:



var data = JSON.parse(response.body);
var myId = data.items[0].id;
variables.set("id", myId);

      

+3


source







All Articles