Grabbing response from API call within backend workflow

Hi fellow bubblers!

CONTEXT
Question to ask - I am working on an app where each user who logs in will be able to connect to a 3rd party app via their users api credentials. Unfortunately the app does not offer tokenization so the raw api credentials need to be passed. As best practice, I know I should be ecrypting the keys before storing them, as well as, only be doing API calls via backend workflows.

PROBLEM DETAILS
The problem I’m facing is - I have parameters I set up that I would like to have populated within my backend workflow from the API response I get. I set my API call to ACTION, that way I can call the API from the backend. I then want to loop through the response I get and create records within each item of the loop. For me to do this, I created parameters for “current position” and “total item count”. For me to obtain the “total item count”, I would need to look at the response received the the API, set the total item count, then perform an insert of each item where the “current position < total item count”. Yet, I cant start this INSERT because the total item count has not been set, which would then cause an endless loop.

QUESTION
I looked all over the forums but I am just not understanding the responses given, so I figured I’d ask here. Can anyone help me understand how I could set the “total item count” parameter of my API response within the backend workflow? This may be an obvious answer and I apologize but my brain fog is real right now over this problem. Any help would be greatly appreciated.

Can you share your workflow settings and preview of the response from API
Are you using schedule on a list?

I am not sure if this is what you’re asking for but here are supported screenshots:



image
image
image

I also am not using schedule workflow on a list and figure that would be a more efficient way of accomplishing this? The problem is, in order to call the backend workflow from the front end, i can chose schedule workflow on a list but it asks for a list which I can not provide because i am not initiating an API call on the front end.

Thanks!

Actually you are trying to do a recursive WF maybe but it could be done (faster and cheaper) using Schedul WF on a list. But this depend of each case and you need to avoid racing issue for example.
There’s no difference between calling it from backend or frontent. You can use schedule on a list too. Also, there’s no problem using DATA instead of action in backend WF. This is just different and again, this is related to each case.
Can you give me more details about your issue for the “insert” that you cannot set? You know the total item count from the reponse of the previous API Call. So I don’t see the issue.

I guess this is a misunderstanding of bubbles UI? in the conditional “parent_current_position < parent_total_item_count” the parent_total_item_count is not set but it resolves to blue.

If you could guide me on best way to accomplish the following:

Example API Response is:

  1. I am trying to run a backend workflow which does an API Call which responds with a structured list:

Item
** Name**
Item
** Name**
Item **
** Name

I want to iterate off of this list and insert each Name into a table within bubble.

I am struggling how to set this up solely in the backend so that I am not executing API calls in the front end and revealing sensitive apikey information.

Hope this helps!

The problem is probably that you are trying to do both step in a single WF.
You should fetch the data from API in WF 1 then schedule the WF 2 where you will loop over items one by one. Or Schedule on a list WF 2.

so recursive loop: WF 1: decrypt data > call API > Schedule API WF 2 (only when result of call API count >= 1)
WF 2 > Create item > schedule API WF (only when total item count is not parent current position)

OR
Schedule on a list, if possible
WF 1 : Decrypt > Call API > Schedule on a list
WF 2: Create item

Wow! I am following your schedule on a list method and I think i’m almost there.

One issue is, the table is receiving the Name as all the names in a string so:

Record 1: Name is Name1,Name2,Name3,Name4,etc…

How do I separate it out so that it is:

Record1: Name is Name1
Record2: Name is Name2
etc…


It looks like each item:Name is evaluating to a list of text, so I know that’s likely the culprit, but how also do I specify to insert only each name?

When you select a type of thing, this will be available as “This typeofthing” in the fields. So it should be something like This servicecategories item’s name

@jici you are magnificent. Thank you so much, this solved it for me :slight_smile:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.