mardi 4 août 2015

How do I set an Enviromental Variable in Postman, from an array, within an array?

I am struggling to extract the data from an array within an array to set as a variable. How would I set the variable from the ID, listed within address

{
"user profile":{
"email_address" : "test@test.com",
"addresses" : [
{
"id": 1
},
{
"id": 2
},
]

For a single array I use

var data = JSON.parse(responseBody); 
postman.setEnvironmentVariable("AddressID",data.user_address[data.addresses.length-1].id);

I'm not quite sure how to use the console log as advised yesterday, if that is the answer to this issue.

Many thanks

Aucun commentaire:

Enregistrer un commentaire