Updating a Bubble List using external API's and arrays - Feeling brave? :)

Hey there,

Thanks for taking a look.

Here’s my simple sounding, yet complex objective:

Update the remittance status of a transaction by calling an external API

I have a type / table of “Transaction” with a remittanceStatus field. We also have a unique Transaction ID and unique Merchant ID fields.

The problem
There is no direct way to get the remittanceStatus of a single transaction using the externalAPI. Instead, we must:

  1. Call the “BatchRun’s” API using the Merchant ID as a parameter to return all the runs for that Merchant in the last 30 days. The response contains a “runs” array, which has multiple entries for the same Run ID but no Transaction ID
  2. Using a combination of Run ID and Merchant ID we can call the “RunTransactions” API which contains all the transcations remitted within that single batch Run. The response contains an array with entries for each Transaction, containing the Transaction ID (which I have in my DB already) and that sweet RemittanceStatus I need.

Questions

  1. First of all… how do I do this?? But more specifically…
  2. I can pass the Merchant ID to the BatchRuns’s API but how do I retrieve / use a list of unique Run ID’s to use in the next API call?
  3. Then how could I use this list of unique Run ID’s to make an individual “RunTransactions” API call to return a list of transaction information to update my database

I’m really familiar with the Bubble backend and API connector, etc so all that is cool it’s just managing the arrays to get what I need. Somewhere in here will be recursive scheduled API’s and perhaps a Make.com job to re-initiate it automatically each evening. My plan is to run the recursive workflow per Merchant as a way of breaking the job down but even so, I’m struggling to find a way to deal with a list of Run ID’s which then gives me a list of Transaction ID’s to then update my list of transactions in my DB.

Notes:

  1. The BatchRun’s API returns many (duplicated) Run ID’s for a single Merchant.
  2. Using a single Run ID we can use the “RunTransactions” API to return many Transactions ID’s per Run
    i.e. A Merchant has many Runs returned as an array and a Run has many Transactions as an array. So it needs a loop in a loop using the two API calls. I just want to update the transactions in my database with the latest transaction status from the third party.

Any help would be appreciated!
Thanks

Have you tried the format as text in the composer?

It’s super simple to use. I use it to receive and send arrays

Thanks @doug.burden.

I’d not considered this but thanks for the suggestion. I’ve done some reading up on it but still not sure how I might implement here…

Would you have any examples of your own that you could share please or more info on how you use with your arrays or how I might use it in the above scenario please?

The feature release makes sense just not sure how to apply it [New Feature] '...:format as text' operator on lists

Ok. Let’s assume we’re posting to an endpoint.

I have an array of id numbers i need to send. so i’ll use 1 variable to iterate through and send all.

Now, i need to tell bubble what i’m sending.

Screenshot 2022-11-16 153146

And the format

and my result would be

Screenshot 2022-11-16 153524

1 Like

You can also nest format text for nested arrays

Play around with that and then once you’re comfortable dive into this video.

Then start playing with your format as text

Awesome, thanks @doug.burden!

I’ll give this a go tomorrow and let you know how I get on!

Thanks again :+1:t3:

You bet. I’m here if you get stuck or have more questions.

Hey @doug.burden,

I need to take you up on your offer as I’m still stuck. Your examples make sense - although I’m getting data rather than posting - it definitely helped. The video you provided I think is the key to all this but this is where I’m stuck, as follows:

At 7:52 in the video when we’re trying to set the “Type of thing” on the action “Schedule API workflow on a list”, I do not have the option to choose my API Call, ListRemittanceRuns from the dropdown list. It just isn’t there. My API call is set to “Action” and is initialised as I’ve chosen it in the first step of the workflow but the only options in the “Type of thing” dropdown are Database tables and API calls set to “Data”. How is it that “Get Post” above is an “Action” API call but appears in this list of “Types of things” and why isn’t my ListRemittanceRuns appearing in this dropdown? Screenshots below.

image
image

I’ve tried to setup data API calls which do appear in the “Type of thing” dropdown but then there is a type mis-match between this and the “List to run on”, results of step 1 as that is a different (action) API call. I’ve since removed the API calls set to “data”

I’ve also tried setting the type of thing to “Text” and formatting the “list to run on” as text but again gives me a mismatch

Any help you can provide would be appreciated! :slight_smile:

Update
I’ve built my API’s in a private plugin so that I can have Dev and Live API keys and endpoints. Out of sheer curiosity, I created the API Call within the Bubble API Connector to see if appears… and it does! This seems like a bug in Bubble which stops “Action” API calls within private plugins appearing in the “types of thing” dropdown. “Data” API calls in a private pluing seem fine.

With this first hurdle done, I can attempt the full solution any pointers are still welcome! :slight_smile:

Make sure ListRemittanceRuns is an action and not data in the connector

Yes, definately an action @doug.burden. I’ve added an update above because I think it’s a bug. I’ll workaround it for now. Thanks!