Mapping bundles from iterator

I’m taking some parsed JSON (collected from 4 API calls)
image
…merging it, and trying to iterate it into a CSV.
image
I don’t know how to work with only collections so I tried adding them to an array, but I can’t get the resulting bundle info to map.
image

Hi!

Let your scenario run at least once, after which (if your merges go well), the expected fieldnames from Flow Control[20] - Iterator should populate after the run.

Think of it as letting your scenario “cache” the custom structure coming out of the iterator.

1 Like

I was expecting that, too, but what you see in the last image is all that I have to work with after running the module several times. I was thinking maybe there’s a way to cheat the values using raw field names, but I forget how to do that. I was hoping someone had a suggestion.

For more assistance, please provide the following

  • Scenario blueprint
  • Output bundles

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

blueprint.json (46.3 KB)

Truncated bundles below

HTTP POST OUTPUT

[
    {
        "statusCode": 200,
        "headers": [
            {
                "name": "cache-control",
                "value": "public, no-store, max-age=0"
            },
            {
                "name": "content-type",
                "value": "application/json; charset=utf-8"
            },
            {
                "name": "expires",
                "value": "Wed, 21 Feb 2024 01:29:41 GMT"
            },
            {
                "name": "last-modified",
                "value": "Wed, 21 Feb 2024 01:29:41 GMT"
            },
            {
                "name": "vary",
                "value": "*"
            },
            {
                "name": "server",
                "value": "Microsoft-IIS/10.0"
            },
            {
                "name": "x-aspnetmvc-version",
                "value": "4.0"
            },
            {
                "name": "x-aspnet-version",
                "value": "4.0.30319"
            },
            {
                "name": "x-powered-by",
                "value": "ASP.NET"
            },
            {
                "name": "date",
                "value": "Wed, 21 Feb 2024 01:29:40 GMT"
            },
            {
                "name": "connection",
                "value": "close"
            },
            {
                "name": "content-length",
                "value": "499"
            }
        ],
        "cookieHeaders": [],
        "data": {
            "timestamp": "2/20/2024 5:29:41 PM",
            "status": "ok",
            "result": {
                "PDCML": {
                    "activeBuy": 1,
                    "sellPrice": 1021.5,
                    "activeSell": 1,
                    "buyPrice": 881.5,
                    "availability": "Unavailable"
                },
                "PB1": {
                    "activeBuy": 1,
                    "sellPrice": 1111.5,
                    "activeSell": 1,
                    "buyPrice": 921.5,
                    "availability": "1-2 Week Delay"
                },
                "PDAE1": {
                    "activeBuy": 1,
                    "sellPrice": 0,
                    "activeSell": 0,
                    "buyPrice": 941.5,
                    "availability": "Unavailable"
                },
                "PD50GRV": {
                    "activeBuy": 1,
                    "sellPrice": 1892.06,
                    "activeSell": 1,
                    "buyPrice": 1413.46,
                    "availability": "Unavailable"
                }
            }
        },
        "fileSize": 499
    }
]

ITERATOR OUTPUT

[
    {
        "key": "GCMH",
        "value": {
            "activeBuy": 1,
            "sellPrice": 1093.49,
            "activeSell": 1,
            "buyPrice": 1020.05,
            "availability": "1-2 Week Delay"
        },
        "__IMTINDEX__": 1,
        "__IMTLENGTH__": 377
    },
    {
        "key": "GCM20",
        "value": {
            "activeBuy": 1,
            "sellPrice": 152.58,
            "activeSell": 1,
            "buyPrice": 111.09,
            "availability": "In Stock"
        },
        "__IMTINDEX__": 2,
        "__IMTLENGTH__": 377
    },
    {
        "key": "GBTD1",
        "value": {
            "activeBuy": 1,
            "sellPrice": 2074.4,
            "activeSell": 1,
            "buyPrice": 1999.7,
            "availability": "1-2 Week Delay"
        },
        "__IMTINDEX__": 3,
        "__IMTLENGTH__": 377
    }
]

This is a known issue, because the Iterator doesn’t know the collection structure of the input array in advance because of the use of array built-in functions.

You’ll just have to manually type in the raw key.

{{20.key}}

{{20.value.buyPrice}}

etc.

This is a known issue when using any of the built-in array functions directly in the Iterator module. Any use of these built-in functions in the Iterator module, like “toArray”, will result in unmappable array values, and you’ll have to manually type in the path.

To avoid this, use a “Set Variable” module first with your array function, then map the resulting array into the Iterator.

2 Likes

This is what I was looking for! I didn’t end up needing the set variable, but manually typing the raw key/values did the trick. Thank you :slight_smile:

1 Like

No problem, glad I could help!

1. If you have a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

others can save time when catching up with the latest activity here, and

  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

2 Likes