3

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

Waqar Haider
  • 929
  • 10
  • 33

1 Answers1

3

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);
Sam Aybar
  • 81
  • 3