Hi, Can anyone help me and provide the tests script to parse the first item of many in an API response message? I am trying to parse the 1st element value called itineraryId in this API response message and save it to an environment variable but having difficulty. I am able to parse the Search ID item successfully but the sub item of Itinerary ID is causing me issues.
Sample API response message:
{
“searchId”: “XXXXXXXXXXXXI=”,
“itineraryDetails”: {
“itineraries”: [
{
“itineraryId”: “CicKJQoQYmNkYmFlNzU0YmRmYTc0YhIPCA4SATEYASIGCgRMQTVLIAE=”,
I’ve already tried*:
This for the Search ID and it works but not sure how to parse and save the 1st Itinerary ID to a environment file object.
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable(“Search ID”, jsonData.searchId);