Creating a dynamic JSON Payload with results of an Array Aggregator

:bullseye: What is your goal?

Hi All,

I am trying to making a dynamic JSON request to an API, the structure needs to look something like this:

{ “export_options”: { “image_format”: “webp”, “image_size”: 800 }, “renders”: [ { “export_label”: “render_1”, “mockup_uuid”: “661cab42-8132-46b3-a244-8a31593084ab”, “smart_objects”: [ { “uuid”: “c37e12f2-b022-4058-8a10-40127364fcd8”, “asset”: { “url”: “https://app-dynamicmockups-production.s3.eu-central-1.amazonaws.com/static/api_sandbox_icon.png” } } ] }, { “export_label”: “render_2”, “mockup_uuid”: “bc256d5e-0e63-4b54-a7b8-4cfb42fea918”, “smart_objects”: [ { “uuid”: “c47871c9-bc64-4143-acad-1c73b0036f46”, “asset”: { “url”: “https://app-dynamicmockups-production.s3.eu-central-1.amazonaws.com/static/api_sandbox_icon.png” } } ] } ] }

It is for creating mutlipl mockups at once for t shirts or mugs etc

The output of my array aggregator looks like this:

I am just confused about how to get it dynamic, i.e. i may want to do 4 mockups, or 10 and the API requires it as one payload, maybe a little in over my head here, any help would be appreciated.

I have tried to build it out as a JSON afterwards but then the array aggregator seems to stop after the first output

:thinking: What is the problem & what have you tried?

I have tried to build it out as a JSON afterwards but then the array aggregator seems to stop after the first output

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey there,

you want to turn the array in a JSON?

Delete the array aggregator and replace it with an Aggregate to JSON module instead and get the JSON directly.

Hi All, I got it working,

If you are wanting a specific JSON structure you can create a data structure in HTTP Post after your array aggregator, it will then allow you to shape your array aggregator to match your JSON payload that you need:

3 Likes

Thanks for taking a minute to come back here and let us know the solution, Jasper! :slight_smile:

1 Like