Need help writing to database with list called from api source

So I wanted to update my database periodically with info from an api call. It looks like I can’t do that directly? I’ve seen a post on the forums where it looks like you have to put the information in a repeating group and then run an api workflow on the group as a list? This seems very roundabout. Is there not a way I can parse a returned list and write it directly to corresponding fields in the database?

3 Likes

You can Schedule an API workflow on a list of API results directly. Below is an example:

2 Likes

Thank you for your reply. I feel like I’m missing something here. Is it possible to see that entire workflow and associated api workflow?

Sure, does this help?

So the selected action is one of type Schedule API Workflow on a list. It schedules an API workflow called savevideos on the (list of) results from an external API Get call to YouTube.

2 Likes

Ok, i think i’m understanding better. Can I see the endpoint savevideos workflow? That is what does the database saving correct?

Yes, it is. It looks like this:

1 Like

Ok, so in your first post the list you run the scheduled workflow on is the result of an api call to youtube, you seem to have an option I don’t have. When I set the list to run on I cannot select items, I have the option for first item, last item but not all items in the list.

Try selecting a ‘Type of things’ that corresponds to your API call. Note that I don’t mean database thing. So in my first post, the ‘Type of things’ “YouTube Items Item” is not a table in my database. I struggled with this before as well, until I realised I could select an API in that type dropdown.

ok, so i can get the database to create entries but as far as saving data from the api call, I don’t seem to be able to create the field variables like you did on your first post. Where you schedule api workflow save videos and you have plist, pvid, etc.

Oh you have to define the endpoint you’re calling such that it takes parameters. Apologies, I should have included this before:

You should then be able to set these parameters from the results of your Particle API call and later use them in saving values to the database.

4 Likes

Great! I had to muddle around a bit but I figured a couple things out for myself. Imagine that. Thank you so much for your time and patience. I was wondering also, is it possible to schedule a repeating workflow based on a schedule without interaction? Again, thank you for all your help. I really appreciate it.

You’re welcome. Yes, the Bubble team recently added the recurring workflow feature, but there are restrictions (for performance reasons) on how frequently you can repeat a workflow, based on your plan. Search the forums for recurring workflows. Personally, I use Zapier to schedule my recurring workflows.

By the way, it may be helpful to others if you would outline the additional things you found and then mark the questions as solved.

3 Likes

Well my issue was that the workflow was saving data to the database but was writing a list of data to a single record. I fixed this by changing the dynamic parameter that was passed to the scheduled api workflow

1 Like

in this screenshot there is a workflow called "ParticleAuth - getDeviceAction and @louisadekoya has “Youtube API - Channels”. What is this step? Is it a custom event to call up the API? I have my API set up fine, I just cannot seem to figure out how this is a workflow on an endpoint. Thanks for any help!

figured it out sorry! my API was setup as DATA not ACTION

Huge thanks to @louisadekoya and @dustin :slightly_smiling_face:
Can we possibly take this a step further to complete this “ultimate” guide for unpacking Json arrays into things?

I’m using a many-to-many architecture for my DB, and I would like to know how to get the freshly created things id’s (workflow 2) so I could then update a thing in (workflow 1)?

Thanks

Are you saying that Workflow 1 calls Workflow 2 to create a bunch of things, which relate back to a thing being created/updated in Workflow 1?

If so, I would actually do the update in Workflow 2. So let’s say in Workflow 1, I create an order ‘Order A’ and then call Workflow 2 to create a bunch of Order Items for Order A. I would pass Order A as a parameter ‘pOrder’ to Workflow 2 and after creating each Order Item in workflow 2, I would update pOrder by adding the Order Item to its list of Order Items.

I hope this helps.

Hey thanks for your prompt reply :smiley:

Yep that is exactly what I was looking to achieve but I thought there was a way to update with “add a list of id’s” in Workflow 1 to avoid adding them one by one in Workflow 2. (trying to keep a light and speedy load)

Man, I hope bubble will have an easier solution for looping through arrays as this workflow is driving me crazy :crazy_face:

Thanks again for your time :+1:

I do essentially what it is you are needing to do in the video posted here:

While I’m talking about interaction between an on-page shopping cart and then passing that data back to Bubble where the order itself is created, receiving a list of items from an API call and then passing them to a Bubble server-side workflow where you want to, one-by-one, turn them into proper Bubble database objects is EXACTLY the same thing.

The “List Popper” server-side action plugin I demonstrate there makes this easy (might even be impossible without it).

(BTW, I should note that it IS worth considering whether you really need to decompose the API response into Bubble objects. In one of my own apps, I thought that was absolutely essential but then – even though it’s kind of a pain – realized that I could just store the API response in its original list form and work around it. The impact of doing the unpacking on your app’s capacity can be significant. Just sayin’)

1 Like

Hey @keith thanks for your solution!
I’ll try your plugin today and see if this fits my needs :+1:

I should note that it IS worth considering whether you really need to decompose the API response into Bubble objects.

I totally agree these workflows are heavy on capacity and when messing around with them I noticed that sometimes my workflow will skip an object ID. Not sure whether this is due to a peak load or a workflow error.

So I’m currently thinking of moving this “Json to DB scrapper workflow” to a cloud RPA solution like UiPath and creating/updating things via Bubble’s database API, which seems much easier for debugging and it will take off the processing load.

Shame really, I would like to keep everything in Bubble but it seems that they have a weak point for heavy workflows.