Trying to pass a list to an API connector, bubble keeps adding a "," comma to the end of the list

I need to pass a list of dynamic integer values to an API.

The list is taken from a group state that changes when a user selects/de-selects a value.

When one value is selected, the API works as it is sent the single value (eg. id = 20)

But if I add a second+ value, the API doesn’t work because the list adds a comma to the last item (eg. id = 20,50,)

I can’t for the life of me find a way to remove that last comma so that the API can accept just id = 20,50

Any help is appreciated!

Can you share api settings and also how you populate the list in dynamic value?
Normally, the way to set this is using :format as text on the list.

API settings are quite basic, here’s how I pass it in Bubble to Xano :


And here’s the call that I make to display the data in my main group:

It is just the model_ids and country_ids I am having trouble with. Here’s how i change the group state when a user selects a country:

Bubble doesn’t add a trailing comma to list. What I believe is that you may have an empty value in your state list.
Did you use step by step an inspect everything in your request (or before with inspect button)? You may find for example value 1 - 20 value 2 - 50 and value 3 - (empty)

I see where you’re coming from, but I even set up a text element that showed the list count, which was accurate (showed 2, but the API was passed the comma at the end despite no empty 3rd value)

Other possible thing to check, but I don’t really believe it, is if your id already contain the comma and this is added to your state list. However, this mean that the list would be 20,50,

You could try to use :join with , but I don’t see axtually how this could help. If you can set your app in public view mode, we can probably see what happen actually.

Insert Current cell's Country's id is not empty on the “Only when…” of the action “Set state ➜ Group Prompt Analytics ⇢ country_ids”

Bubble only spits out a trailing , when there’s an empty item hiding in the list.

Hey @greyginter, as a temporary fix, I think you could try adding a filter to avoid empty values. It’s weird you’re getting that extra comma without an extra value in the list

If that’s not the issue, then you should try copy/pasting the URL on the API connector on a text editor to look for the extra comma there

Edit: typo

you can try this

do a search for things (this will be list of entries) then, minus last item, then append ,last item

i hope your issue will be resolved if not you can schedule meeting with me i am happy to assist you (Calendly)

I’m wondering how you can come with this (not) solution? Did you read the post ? Understand the issue? The user settings and process?

Thanks for the help, but there was no empty list item being added so I had to find a workaround.

I created a new element state that saved a single line of text, updated with the existing state value with :append “,” and :append “thing’s ID” when not empty, and just the "thing’s ID’ when empty. That way I just had a single line of text looking like “28,170” that I then split using a function in my Xano backend after it was passed to the API.

Removing id values from the list was a bit trickier, but I figured out that if I replaced the id value I wanted to remove with a comma, the list would go from “28,170” to just “28,” and then I could
find&replace any double commas “,” with nothing to remove them. Also worked with long lists like 28,170,210. If I were to remove 170 it would become 28,210 then replacing one of those double commas left 28,210.

Edit: this post isn’t showing the double commas so that doesn’t look like it makes sense but it works.

1 Like