How to Save Multiple Items from API Response to Database List Field?

PHi Bubble community,

I’m struggling with saving multiple items from an API response into a database list field and could use some guidance.

My Setup:

Database:

  • Table: MyDataType

  • Field: my_list_field (type: list of option sets)

  • Option values include: option_a, option_b, option_c, etc.

API Connector:

  • External worker that returns parsed data

  • Response includes a my_list_field field

  • Currently configured as “option set” in API Connector

API Response Example:

my_list_field: "option_a,option_b"

(comma-separated string with values that match my option set)

The Problem:

When I try to save this to my database using:

Make changes to MyDataType
  my_list_field = This MyDataType's my_list_field:merged with 
                  Result of step X's my_list_field:converted to list

What happens: Both items get saved as ONE concatenated item: option_aoption_b

What I want: Two separate items in the list: option_a AND option_b

What I’ve Tried:

  1. Returning an array from the API (Bubble sees it as “list” but still doesn’t split properly)

  2. Using :split by "," (option not available when field is option set)

  3. Using :converted to list (concatenates items instead of splitting)

  4. Changing API field type between “text”, “option set”, and “list”

Questions:

  1. What’s the correct way to configure the API Connector return field for this use case?

  2. What expression should I use in the workflow to properly split and save multiple option set values?

  3. Should the API return a string, an array, or something else?

Any help would be greatly appreciated! I’ve been going in circles for hours.

Thanks in advance!

Can you provide the whole response from API? Is it a JSON?

API response is json, this is one response for option medical,_condition were returinging this array that should match the option set options, when it saves it in the workflow it saves ““ value? here is the API treturn “medical_conditions”: [
“diabetes_endocrine”,
“mobility_bone_injury_recovery”,
“respiratory_breathing”,
“heart_circulation”
],

Cannypu share how you have paste it in API connector ? As a list of text?

when you make changes, you should probably use get an option then select your option set, filter by the ones whose display is in the api response and set list instead of merge. something like this.
here’s the editor link to see the setup

Inside API connector, reinitialize and set that key value to be option set instead of text. Ensure your option displays value match what api returns exactly. Then bubble will interpret those values as options instead of text.

ok, solved it, had to clean by creating a new and updated option set and use lower case and no space naming. Once this was cleaned out the api and bubble noticed each other and stored the value’s. thanks to all who replied

1 Like