Relatively new user here so hopefully I’m not missing something basic. I did search the community forums and noticed that a few others ran into this in 2020-21, so I’m hoping it’s been fixed now.
I’m trying to parse data from an API endpoint whose response is a combination of regular and array elements. Sample response:
When I set up the collection and give it a “results key” that is defined as an array (“workout_counts” in my example), all seems good (it shows all the key-value pairs in the response including “id” and it lets me save the collection)
but the only key results that get saved to the collection are the ones in the “workout_counts” array (i.e name, slug and count from my example above). No “id” or anything outside the “workout_counts” array. Which makes sense.
But what I want to get is the value of the “id” key. if I enter “id” as the “results key” and this time, the response after the “test” looks exactly the same as before, except it indicates this error up top and won’t let me create the collection
Which leads me to believe that the Adalo external collections custom API indication does not support parsing out non Array JSON elements. Is this correct? If so, how are people dealing with this limitation? (I have to think that there are other apps out there query JSON responses for non array elements!)
You are correct that only arrays can be collections. An external collection can also not have nested arrays.
I would need to see the use case, but having your endpoint return an array is important, so it would be:
I guess by the time my post got passed the spam moderator I’ve found a workaround. I set up a “Custom Action” and this is able to return all the values. The only challenge seems to be that this can only happen on specific user actions and I’m not sure about the performance cost of this vs making API calls with the “External Collections”. Any inputs on these would be appreciated.
Thanks for the reply Steven (@TKOTC). Unfortunately, I do not control the API response because that is from a public API of a fitness device. I supposed I could dump the data form the public API into some other database (like Airtable or something) and then expose an API endpoint that Adalo likes. That would have been the next thing I would have pursued if the custom actions didn’t work out.
Thanks so much! - I’ll give this a shot if custom actions does not work out for what I’m doing right now. Either way, I think at some point I’ll have a use case for creating an intermediary datastore that can feed into other places (incuding adalo) so your video will be very helpful then!
Out of curiosity, have you had much experience with custom actions. Are the main limitations the ones I outlined above? namely:
Only triggered on a user action?
Higher cost and performance hit since it happens at run time?
You can trigger it on page load as well, HOWEVER, there is a bug that does not allow you to use the results of the custom action if you do it on page load. So if you are saving results to an external source, custom action on page load is fine. If you want to retrieve information to display on page load, this is broken.
The performance cost is about the same between custom action and external collection.
You cannot use nested arrays. Adalo will convert the array to an object, so in the example above, you will think it works because you will see workout_counts > name, but what Adalo does is
Thanks for the clear explanation. Now that I’m aware of the limitations, I feel like I can workaround them a bit with some design hacks. I appreciate the quick replies and will mark this as solved.