Unable to fetch nested data in API response

In my setup, I have courses, and each course contains lessons, sections, and videos. When I fetch courses via API, I only get the related IDs (lesson IDs, section IDs, video IDs), but not the actual nested data.
Because of this, I am unable to provide complete course details to my mobile developer in a single API response.
What I need is a way to return the full nested data (lessons, sections, and videos with their details) directly inside the course API response, instead of just the IDs. Could you please advise how to configure this in backend workflow of Bubble.io?

You are talking about the Data API from Bubble?

Bubble will provide the unique ID and you need to a another call to fetch related data with this unique ID.

You can solve this by instead use Backend WF API and Return Data from API. You could also use a custom response format and build your own JSON using this way (but it’s more complex to build your own response with a custom JSON…)

As I’m using the Backend WF to return data from the API, I’m facing an issue. In “Search for Courses: format as text”, the “Return data from API” content should be a list of courses, but right now it’s coming as text.
The problem is that I need nested data from my API call, but it’s only returning the IDs.
For example, I have courses, and inside them, there are sections, lessons, and videos. But instead of returning their data, it’s just returning their IDs.

Can you share your settings for Return data from API and format as text… If you use custom body, you need to properly encode it as JSON yourself…

here are the screenshots

You are not using a custom body but the formatted JSON and you are trying to “cheat” it there. It won’t work. If you use structure JSON, you should just have a Search for courses (nothing else). Bubble will encoding correctly. However, it will be similar as what you have in Data API. The difference, i that you can use more key like “Sections” and have another part of your JSON that will show Sections. But… this is not well structure as this will be a different object at the root of the JSON instead of nested (but it can work too.. just more complex to handle).

Switch the content-type to “Other content-type”, set custom type to: application/json, and encode your JSON into the box under the custom type field. Don’t forget that you will need to set array correctly so it should be: [Do a search for:format as text] (include the square brackets)