Performing a GET request that returns in XML format. I converted that to JSON as outlined below. I am looking to parse an array and set an array as an env variable for each specific object in the array.
Path to data I want to retrieve:
BESAPI.Query.Result.Tuple.Answer[0]._
Here is my action script:
var jsonData = xml2Json(responseBody);
var ActionIDs = [];
_.each(jsonData.BESAPI.Query.Result.Tuple[0].Answer[0]._, () => {
ActionIDs.push(jsonData.BESAPI.Query.Result.Tuple[1].Answer[0]._)
})
pm.environment.set("ActionID", ActionIDs.shift());
pm.environment.set("ActionIDs", JSON.stringify(ActionIDs));
pm.test("Status code is 200", function () {
console.log(pm.response.code);
pm.response.to.have.status(200);
});
Attached a screenshot of my JSON response body. How can I achieve looping through Tuple.Answer to get all highlighted values for each object from the response? With the current test scripts I am getting the following in my ActionIDs env variable:
["1965555","1965555","1965555","1965555","1965555","1965555"]!