Quick Assistance With Nested Objects

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:


Here is my action script:

var jsonData = xml2Json(responseBody);

var ActionIDs = [];

_.each(jsonData.BESAPI.Query.Result.Tuple[0].Answer[0]._, () => {

pm.environment.set("ActionID", ActionIDs.shift());

pm.environment.set("ActionIDs", JSON.stringify(ActionIDs));

pm.test("Status code is 200", function () {


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:


Hey @austin4778

Something like this should create an array of those values and store them as an environment variable:

let jsonObject = xml2Json(responseBody),
    ActionIDs = [];
_.each(jsonObject.BESAPI.Query.Result, (arrItem) => {
    _.each(arrItem, (result) => {

pm.environment.set("ActionIDs", JSON.stringify(ActionIDs));

Thank you very much! My syntax was a little off :blush: