I have an external API that if returns an object if it is 1 item, or a list of those objects when it is more than 1. The issue that bubble runs in too, is that it seems to know only 1 version. I have a repeating group which calls the API fine and returns the list version but cannot seem to get data from the single one.
Is there a way in Bubble to hand this inconsistent data type?
For me, it’s an error on the API server side. However, you can handle this by
- Enter manually a merged payload of both possible responses in API connector
- use a conditionnal yo show a group or a repeating group according to the response
It absolutely is an API issue but don’t have much choice.
What do you mean by manually merged? I am not sure how to detect on API call level
In API connector, you have an option to manually enter response. Create a merge of single item and the list response. But this also depend of the payload of the API. Can you share url to api doc or share the two payload you are receiving.
What do you mean by creating a merge of single and the list response? Manually input is JSON, or is there a way to put logic there? I see no place to put OR logic or any manipulation of payload.
Currently, I am playing around with Postman Flows to turn objects into a list
The endpoint in question is JazzHR API
There’s no informations about the possible responses.
Let’s say the json for a single item is {"key":"value"}
and for a list [{"key":"value"}]
You will need to create two call, call one of them, and if this is empty, call the second one.
This is the most common case. In some case, you can merge two different answer in podioand use manually enter API response.
So the calls are not empty, they just have different structures depending if it is 1 or greater than 1. What I ended up doing is making a call to Postman Flow, doing the logic in flow and returning a consistent object via webhook back to Bubble. The repeating group then has a data source of the thing, that the webhook updates.