Adding a variable number of API parameters

I want to connect my app to HERE technologies via Bubble API connector.
The screenshot below is working fine, even when inserting dynamic values in the parameter, see raw JSON response.

The problem here is that I will not have always a fixed number of waypoints(AKA destinations) to optimize, the number of destinations will vary depending on user input, so some users could insert 3 destinations to optimize while others will input 50.

How can I dynamically add parameters depending on the number of destinations that the user has inserted?
Ex. the user inputs 3 waypoints to optimize, the bubble app will automatically “create” 3 parameters (destination1, destination2, destination3) and pass them to the API call
if the user inputs 5 waypoints to optimize, the bubble app will automatically “create” 5 parameters (destination1, destination2, destination3, destination4, destination) and pass them to the API call
API documentation by HERE: HERE Technologies Documentation | HERE Docs

There are 2 ways of doing this:
(1) Add in 50 parameters but make them optional. Then send the necessary amount of parameters depending on what the user types in.

(2) Have one parameter for waypoint and construct the JSON array in the ‘workflow’ section using the arbitrary text command. You’ll probably need a looping method to construct the JSON array before passing it into the waypoint parameter.

1 Like

Thank you!
What is the name of the key I should insert in bubble so that he “understands” that it is an array?
I tried destination it seems that it is not working, if I insert the associated value: destination1=FranfurtCentralStation;50.1073,8.6647&destination2=DarmstadtCentralStation;49.8728,8.6326&destination3=FrankfurtAirport;50.0505,8.5698&destination4=HanauCentralStation;50.1218,8.929

If I initialize the call like this the raw data is not including the waypoints, just the starting and the ending one,

When i took a closer look at the api docs, you can consider using url parameters for that part of the call instead.


You can follow the setting above using square brackets to set parameters. for destination ‘key’, the square bracket will contain the full destinations key and value (i.e. &destination1=xxx&destination2=xxx and so on,)

That should work for your call.

1 Like

Is this API call done in the front end? The reason I ask is you can use the Toolbox plugin, with the ListOfNumbers element, that will generate the numbers 1-10 (for 10 destinations), then you can do your api call and reference the element's list of numbers:formatted as text and dynamically put in the destination[This number} and put an & between all of them as the delimiter.

EDIT: nvm don’t think that would work because you need to do the :formatted as list operator on the list of destinations, but then you won’t have the number available.

1 Like

That works, thank you!
Now if I want to set destination number dinamically, using arbitrary text in the workflow, should I install Toolbox and try to do it with some script? Or is it possible with Bubble dynamic fields? Do you have recommendations on how to approach that?
Thank you