I'm trying to parse the value of "id" from the JSON body response to include in an environmental variable in Postman with no success. Here is an example of the Body response.
"payload": {
"transaction": {
"amount": "1.00",
"id": "114255633",
"type": "AUTH",
"result": "APPROVED",
"card": "XXXXXXXXXXXX1111",
"authorization-code": "TAS977",
}
}
and here is my script in postman
var jsonData = JSON.parse(responseBody);
var id = jsonData.payload[0].transaction.id;
postman.setEnvironmentVariable("id", id);
Any help would be appreciated. I think my error is in the way the value I'm looking to get is nested inside an array.