📦 Help transforming grouped order line items into JSON payloads for HTTP POST

Hi all — I’m trying to transform incoming order line items into structured order payloads in, and could use some help getting the data transformation right.

###:receipt: Input Data

This is the data being sent into my webhook. It’s a flat array of order line items. Each has a transaction_number (which acts like an order ID), and I want to group these into orders with their respective line items.

[
  {
    "id": 101001,
    "upc": "123456789012",
    "quantity": 48,
    "order_type": "R",
    "item_number": 10001,
    "customer_type": "L",
    "customer_number": 11111,
    "transaction_type": "BO",
    "delivery_datetime": "2025-06-18T05:00:00Z",
    "transaction_number": "TX100001",
    "transaction_datetime": "2025-06-16T17:46:12Z",
    "delivery_instructions": "Back entrance"
  },
  {
    "id": 101002,
    "upc": "123456789013",
    "quantity": 24,
    "order_type": "R",
    "item_number": 10002,
    "customer_type": "L",
    "customer_number": 22222,
    "transaction_type": "BO",
    "delivery_datetime": "2025-06-18T05:00:00Z",
    "transaction_number": "TX100002",
    "transaction_datetime": "2025-06-16T16:24:57Z",
    "delivery_instructions": "Leave at reception"
  },
  {
    "id": 101003,
    "upc": "123456789014",
    "quantity": 24,
    "order_type": "R",
    "item_number": 10003,
    "customer_type": "L",
    "customer_number": 11111,
    "transaction_type": "BO",
    "delivery_datetime": "2025-06-18T05:00:00Z",
    "transaction_number": "TX100001",
    "transaction_datetime": "2025-06-16T17:46:12Z",
    "delivery_instructions": "Back entrance"
  }
]

:white_check_mark: Desired Final Output

For each unique transaction_number, I want to POST a single order payload that looks like this:

:small_blue_diamond: TX100001 (has 2 items):

{
  "topic": "order_create",
  "order": {
    "id": null,
    "transaction_number": "TX100001",
    "order_type": "R",
    "customer_type": "L",
    "customer_name": null,
    "customer_number": "11111",
    "transaction_date": "2025-06-16T17:46:12Z",
    "delivery_date_requested": "2025-06-18T05:00:00Z",
    "delivery_instructions": "Back entrance",
    "time_stamp": "2025-06-26T14:10:25.402Z",
    "order_items": [
      {
        "order_item_id": 101001,
        "quantity_requested": 48,
        "product_number": "10001",
        "upc": "123456789012"
      },
      {
        "order_item_id": 101003,
        "quantity_requested": 24,
        "product_number": "10003",
        "upc": "123456789014"
      }
    ]
  }
}

:small_blue_diamond: TX100002 (1 item):

{
  "topic": "order_create",
  "order": {
    "id": null,
    "transaction_number": "TX100002",
    "order_type": "R",
    "customer_type": "L",
    "customer_name": null,
    "customer_number": "22222",
    "transaction_date": "2025-06-16T16:24:57Z",
    "delivery_date_requested": "2025-06-18T05:00:00Z",
    "delivery_instructions": "Leave at reception",
    "time_stamp": "2025-06-26T14:10:25.402Z",
    "order_items": [
      {
        "order_item_id": 101002,
        "quantity_requested": 24,
        "product_number": "10002",
        "upc": "123456789013"
      }
    ]
  }
}

:folded_hands: What I need help with

I’m looking for the best way to transform the grouped array into this JSON structure. I’ve already used an [Array Aggregator] module to group items by transaction_number, so I’m working with a bundle that contains the array of items for each order. I’ve also used the [Text Aggregator] to transform the field name and shape the JSON file the way I want it. The issue now is that I can’t get the array of items to list out properly. I am quite new to this world.

If you’ve tackled something like this, I’d love your insight :folded_hands:.

Thanks in advance!

I should add that the closest I’m getting is inserting the array but then it includes all the information all over again in a long string.

All this said, in trying to get you this updated information, I just realized the whole thing is one long string when I download the output so maybe it’s all wrong!? how the heck doI get this data to look the way I want to in the example above?!

Here is the output:

[
    {
        "text": "{\n  \"topic\": \"order_create\",\n  \"order\": {\n    \"id\": \"null\",\n    \"transaction_number\": \"TX100001\",\n    \"order_type\": \"L\",\n    \"customer_type\": \"L\",\n    \"customer_name\": \"null\",\n    \"customer_number\": \"11111\",\n    \"transaction_date\": \"2025-06-16T17:46:12Z\",\n    \"delivery_date_requested\": \"2025-06-18T05:00:00Z\",\n    \"delivery_instructions\": \"Back entrance\",\n    \"time_stamp\": \"2025-06-27T02:57:46.531Z\",\n    \"order_items\":  [\n     {\"id\":101001,\"upc\":\"123456789012\",\"quantity\":48,\"order_type\":\"R\",\"item_number\":10001,\"customer_type\":\"L\",\"customer_number\":11111,\"transaction_type\":\"BO\",\"delivery_datetime\":\"2025-06-18T05:00:00Z\",\"transaction_number\":\"TX100001\",\"transaction_datetime\":\"2025-06-16T17:46:12Z\",\"delivery_instructions\":\"Back entrance\"}, {\"id\":101003,\"upc\":\"123456789014\",\"quantity\":24,\"order_type\":\"R\",\"item_number\":10003,\"customer_type\":\"L\",\"customer_number\":11111,\"transaction_type\":\"BO\",\"delivery_datetime\":\"2025-06-18T05:00:00Z\",\"transaction_number\":\"TX100001\",\"transaction_datetime\":\"2025-06-16T17:46:12Z\",\"delivery_instructions\":\"Back entrance\"}\n    ]\n  }\n}",
        "__IMTKEY__": "TX100001"
    },
    {
        "text": "{\n  \"topic\": \"order_create\",\n  \"order\": {\n    \"id\": \"null\",\n    \"transaction_number\": \"TX100002\",\n    \"order_type\": \"L\",\n    \"customer_type\": \"L\",\n    \"customer_name\": \"null\",\n    \"customer_number\": \"22222\",\n    \"transaction_date\": \"2025-06-16T16:24:57Z\",\n    \"delivery_date_requested\": \"2025-06-18T05:00:00Z\",\n    \"delivery_instructions\": \"Leave at reception\",\n    \"time_stamp\": \"2025-06-27T02:57:46.532Z\",\n    \"order_items\":  [\n     {\"id\":101002,\"upc\":\"123456789013\",\"quantity\":24,\"order_type\":\"R\",\"item_number\":10002,\"customer_type\":\"L\",\"customer_number\":22222,\"transaction_type\":\"BO\",\"delivery_datetime\":\"2025-06-18T05:00:00Z\",\"transaction_number\":\"TX100002\",\"transaction_datetime\":\"2025-06-16T16:24:57Z\",\"delivery_instructions\":\"Leave at reception\"}\n    ]\n  }\n}",
        "__IMTKEY__": "TX100002"
    }
]

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of four modules:

Two bundles, one for each order:

This is just an example. Your final solution may or may not look like this depending on your requirements.

Hope this helps! Let me know if there are any further questions or issues. P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!

@samliew

1 Like

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":66,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"[{\"id\":101001,\"upc\":\"123456789012\",\"quantity\":48,\"order_type\":\"R\",\"item_number\":10001,\"customer_type\":\"L\",\"customer_number\":11111,\"transaction_type\":\"BO\",\"delivery_datetime\":\"2025-06-18T05:00:00Z\",\"transaction_number\":\"TX100001\",\"transaction_datetime\":\"2025-06-16T17:46:12Z\",\"delivery_instructions\":\"Back entrance\"},{\"id\":101002,\"upc\":\"123456789013\",\"quantity\":24,\"order_type\":\"R\",\"item_number\":10002,\"customer_type\":\"L\",\"customer_number\":22222,\"transaction_type\":\"BO\",\"delivery_datetime\":\"2025-06-18T05:00:00Z\",\"transaction_number\":\"TX100002\",\"transaction_datetime\":\"2025-06-16T16:24:57Z\",\"delivery_instructions\":\"Leave at reception\"},{\"id\":101003,\"upc\":\"123456789014\",\"quantity\":24,\"order_type\":\"R\",\"item_number\":10003,\"customer_type\":\"L\",\"customer_number\":11111,\"transaction_type\":\"BO\",\"delivery_datetime\":\"2025-06-18T05:00:00Z\",\"transaction_number\":\"TX100001\",\"transaction_datetime\":\"2025-06-16T17:46:12Z\",\"delivery_instructions\":\"Back entrance\"}]"},"metadata":{"designer":{"x":869,"y":-1523,"name":"Example Input"},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":67,"module":"builtin:BasicAggregator","version":1,"parameters":{"feeder":66},"mapper":{"id":"{{66.id}}","upc":"{{66.upc}}","quantity":"{{66.quantity}}","order_type":"{{66.order_type}}","item_number":"{{66.item_number}}","customer_type":"{{66.customer_type}}","customer_number":"{{66.customer_number}}","transaction_type":"{{66.transaction_type}}","delivery_datetime":"{{66.delivery_datetime}}","transaction_number":"{{66.transaction_number}}","transaction_datetime":"{{66.transaction_datetime}}","delivery_instructions":"{{66.delivery_instructions}}"},"metadata":{"designer":{"x":1118,"y":-1524,"name":"Aggregate by Order"},"advanced":true},"flags":{"groupBy":"{{66.transaction_number}}","stopIfEmpty":true}},{"id":69,"module":"builtin:BasicFeeder","version":1,"parameters":{},"mapper":{"array":"{{67.array}}"},"metadata":{"designer":{"x":1363,"y":-1524,"name":"Iterate Items"}}},{"id":70,"module":"util:TextAggregator","version":1,"parameters":{"rowSeparator":"other","otherRowSeparator":",","feeder":69},"mapper":{"value":"{\r\n  \"order_item_id\": {{69.id}},\r\n  \"quantity_requested\": {{69.quantity}},\r\n  \"product_number\": \"{{69.item_number}}\",\r\n  \"upc\": \"{{69.upc}}\"\r\n}"},"metadata":{"designer":{"x":1606,"y":-1525,"name":"Aggregate Items"},"parameters":[{"name":"rowSeparator","type":"select","label":"Row separator","validate":{"enum":["\n","\t","other"]}},{"name":"otherRowSeparator","type":"text","label":"Separator"}],"advanced":true},"flags":{"stopIfEmpty":true}},{"id":73,"module":"util:ComposeTransformer","version":1,"parameters":{},"mapper":{"value":"{\r\n  \"topic\": \"order_create\",\r\n  \"order\": {\r\n    \"id\": null,\r\n    \"transaction_number\": \"{{67.array[].transaction_number}}\",\r\n    \"order_type\": \"{{67.array[].order_type}}\",\r\n    \"customer_type\": \"{{67.array[].customer_type}}\",\r\n    \"customer_name\": null,\r\n    \"customer_number\": \"{{67.array[].customer_number}}\",\r\n    \"transaction_date\": \"{{67.array[].transaction_datetime}}\",\r\n    \"delivery_date_requested\": \"{{67.array[].delivery_datetime}}\",\r\n    \"delivery_instructions\": \"{{67.array[].delivery_instructions}}\",\r\n    \"time_stamp\": {{now}},\r\n    \"order_items\": [{{70.text}}]\r\n  }\r\n}"},"metadata":{"designer":{"x":1853,"y":-1526,"name":"JSON for order","messages":[{"category":"last","severity":"warning","message":"A transformer should not be the last module in the route."}]}}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Unreal - are you going to be my new best friend?! Thank you so much @samliew. This is what I needed!

In my countless iterations I wonder about an aggregator followed by an iterator but never managed to bring it together. This is exactly what I needed. Wishing you a great day!

1 Like