How to create several items from a json list of items

Hello, im using the api connector to get a list of contacts. I now want to take this list of contacts and add it to my app data. I’m currently only able to create one actual contact in my app( the first contact or last contact i get from the api response). Any help is appreciated!

1 Like

Yeah, if you want to convert an array type object coming from the API Connector to separate Bubble things (like a Contact datatype in your database), you need to snag the API response and then iterate over it to unpack it into individual values that can be saved in Bubble.

This is endlessly frustrating, of course. (I call this effect “the API Ghetto” – list type

You can either do this type of iteration as an API Workflow on a list (the list in question is the list response from the API), or do it with some custom JavaScript in a page, or you could run a recursive API Workflow, now that those are allowed.

You may or may not find that the server-side options are fast enough for you.

What I wish is that one could say of such lists: “Look, Bubble, this is a list of type Some Real Type in my Database, not ‘custom response from API’.”

And then the things would actually exist in the database as objects of that type. As it is now, they DO EXIST in the database, if you save them there (as a list object blob) and so they take up storage, but they cannot be manipulated in any useful way without first iterating over them in the way I describe above. Meh.

5 Likes

Hi Keith, can I ask a related question? I want to send a list of unique IDs related to a Thing for indexing on Algolia, along with other fields from the Thing. When I use the notation thingIDs: [“thingIDsFromBubble”], though an array is created in Algolia, it just has a single value of all IDs separated by commas.

Is there a way of separating a list of values from a Bubble field into individual components of an array in a PUT request?

  • Actually I worked this out - you can use ‘join with “,”’ to achieve this. Thanks anyway :slight_smile:
1 Like

Hey @keith , list master :slight_smile: ,

Do you mind taking a look a this post? I wanted to post the text here but seems more accurate performance wise to just put the link :).

http://forum.bubble.io/t/xano-database-bubble-demo/196758/59?u=ryanck

Thanks a lot man.

lol! I’m in the API ghetto again. Note to future users. Schedule and API workflow on a list, so you’ll two api workflows. List to run on is the datatype of the returned data from the api call, the json object. use this(item)s id, name etc to match to your db in bubble. Map your key value pairs in the workflow you use to run on the list and pass the this(items) api value to the workflow you’ll run the list on.