API Workflows - Returning list items inside a list

Hi all,

I’m trying to return some nested JSON on an API call to Bubble and I just don’t get what the process should be:

I have an Order data type with a few fields including a list of Assigned Items, which have their own data type. One Order can have multiple Assigned Items and each Assigned Item has only one Order.

I can return a list of Orders just fine but I’ve no clue how to include associated Assigned Items in the same JSON, is this at all possible?
e.g.
[
{
“id”: 4
“assigned_items”:[
{
“id”: 2,
“item_name”: “Item”
},
{
“id”: 8,
“item_name”: “Item 2”
}
]
}
]

Well first of all, the JSON looks funny. I would expect something like this:

{
  "order-id": "test1234",
  "order-lines": [
              {
              "orderline": "1",
              "run_01": 50,
              "run_02": 0,
              "run_03": 0
              },
              {
              "order-line": "2",
              "run_01": 50,
              "run_02": 0,
              "run_03": 0
              }
  ]

Do you have some API documentation? After that when Initializing the call in Bubble you would be able to set it a a list (it does automatic)

Thanks for replying @martijntenpas - I think I may have confused the issue a bit: I’m making a call to an API workflow to get data out of Bubble to an external site, not passing data into Bubble.
Thanks!

This is what the JSON should look like, I will try to show you some screenshots of how to get the data out of bubble using a backend workflow.

{
"orders": [
    {
        "order_id": 1,
        "items": [
            {
                "item_id": 1,
                "item_name": "Laptop"
            },
            {
                "item_id": 2,
                "item_name": "Mouse"
            }
        ]
    },
    {
        "order_id": 2,
        "items": [
            {
                "item_id": 3,
                "item_name": "Monitor"
            }
        ]
    },
    {
        "order_id": 3,
        "items": [
            {
                "item_id": 4,
                "item_name": "Keyboard"
            },
            {
                "item_id": 5,
                "item_name": "USB Cable"
            }
        ]
    }
]
}

Here you go see see :point_up:

Hi @J805 That’s precisely what I’m after, any help is really appreciated

Let me know if that helped. :blush:

And now I’m slamming my head on the desk after trying to keep the content type as JSON.
That should do the trick, many thanks!

1 Like

No worries. Glad that helped! :blush::raised_hands:

This topic was automatically closed after 70 days. New replies are no longer allowed.