Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Dynamic Data and Request Chaining Runscope

Tags:

json

runscope

When the first step return a json object like this

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

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

i have done it like this but it didn't work

enter image description here

i also tried items.id, items[0].id but that didn't work either

like image 773
Waqar Haider Avatar asked Sep 12 '26 09:09

Waqar Haider


1 Answers

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);
like image 78
Sam Aybar Avatar answered Sep 18 '26 11:09

Sam Aybar