JSON body, Key with additional Sub Keys

Hi all.

Just wondering how you set up json body's in retool that require key's within keys?
When i query directly through my swagger site using application/json it would look like the below(sample).

{
  "Id": 1,
  "SaleDate": "2023-09-22T15:45:44.8361156+10:00",
  "Member": {
    "Id": "5000016",
    "Classifications": [
      {
        "Id": 2,
      }
    ],
  },
  "Items": [
    {
      "Id": 16332,
      "Quantity": 1,
      "Price": 0,
      "InventoryCode": "16332"
    }

As you can see i have a 2 main keys in this example being ID and Items with ID having 4 sub keys being Saledate, Member, ID, and classification.

How do you set something like this up in retool?

Screenshots.

Swagger


CURL
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'ApiKey: apikey' -d '{ \
"Id": 1, \
"SaleDate": "2023-09-22T15:45:44.8361156+10:00", \
"Member": { \
"Id": "5000016", \
"Classifications": [ \
{ \
"Id": 2, \
} \
], \
}, \
"Items": [ \
{ \
"Id": 16332, \
"Quantity": 1, \
"Price": 0, \
"InventoryCode": "16332" \
} \
], \
"Media": [ \
{ \
"Id": 7, \
"Amount": 0, \
"VoucherBarcode": "446109387525565" \
} \
], \
"SuppliedVouchers": [ \
{ \
"Barcode": "446109387525565", \
} \
] \
}' 'Our endpoint address'

Cheers

It really depends what you mean by set up - in a table or another component? You may have to transform it a little bit just to get at the data you want and display it.

Thanks! i was overly complicating something simple.

@pete82 thanks for asking here and thanks @ScottR for pointing toward transforming the data a bit.

@pete82 any chance you could share some brief notes on what solved this for you, in case others out there find this post and are looking for how to do something similar?

Hi KBN,

It was just how i was structuring it within the key for the api call.

[{ "Id": {{ KeyTicketDetails.data.Id }}, "Quantity": 1, "Price": 0, "InventoryCode": {{ KeyTicketDetails.data['Inventory Code'] }} }]