Adding List of Things to API connector

Seems like quite a few people have been bringing up API and “lists” in the forum. Is it something we can expect soon?

How would you go about solving this with what we have available already? (I’m thinking custom workflow, however open to any suggestions)

What people were asking was ability to fetch lists, and we did solve that already.

Here you’re asking about input, which is more complex, and a much more rare case.

To follow up. Any chance this will be implemented soonish? I can add recipients one by one however it will be sorta killing the workflow if other users of my app will do the same.

I can’t commit on adding that in the coming weeks.

That’s alright. I’ll sort it out another way. (I hope)

Speaking of which: How can I send a list of things to Blockspring so it fills in as a table?

Right now if I run a block: “Append values to a Sheet”, I enter the following into JSON input:
[[“List of things first_names”, “List of things last_name” ]]

RESULT:
Column A Column B
Row 1 Bernie, Hillary, Donald “Sanders, Clinton, Trump”

I can add one column of repeating group by entering JSON:
[["List of Things first name joint with “],[” "]]

        Column A

Row 1 Bernie
Row 2 Hillary
Row 3 Donald

How can I get Blockspring to enter it into the table with both first and last name like this:

        Column 1   Column 2

Row 1 Bernie Sanders
Row 2 Hillary Clinton
Row 3 Donald Trump

(Or is this pretty much the same issue and I can’t do it?)

Hi Martin, same issue with populating blockspring tabel, haw had you solved finally?
Thanks a lot
Andrea

Hi @adycarlo, I can think of a couple of ways to do this.

1 . If you are initiating the send from a browser, and the user has access to all the data sending, could build up the list with the Toolbox plugin List Item Expression.

2 . If the API call is from an API workflow step, i.e. from the server, could send the following to an external host …

{
“email”: [“jones@example.com”,“miller@example.com”, …],
“last_name”: [“Jones”, “Miller”, …],
“pet”: [“Fluffy”, “FrouFrou”, …]
}

and have it return back a structured form
[
{ “email”: "jones@example.com", “last_name”: “Jones”, “pet”: “Fluffy” },
“email”: "miller@example.com", “last_name”: “Miller”, “pet”: “FrouFrou” },

}

How often does it need to run? If its infrequent, could use a free webtask.

3 . Build up the text for each item as it is created / updated.

1 Like

Hi @emmanuel! I was wondering if this feature of inputting a list to the POST body will ever be added? I would love this feature and currently there is no seems to be no workaround sending a list of data to the API connector (or even converting a list to a string). Any input would be helpful!

Have you tried this?

Thanks for the input @renelonngren! I need something specifically for the API and no element related. So I want to send a POST request with the body containing a List of Things in the Bubble database (e.g. Users). If you know of a plugin/method that is able to send a List of Things from Bubble to an external API that would be fantastic!

Ive used the above plugin to do that. I send a list of users with their respective names and emails to Sendgrid as a json using the plugin.

1 Like

Oh, do you have an example (or directions) for that? I cannot seem to see any plugin action in the API workflow or in the API connector that will allow me to do that.

@gbannister So, first, after reviewing my app, the plugin to use is Toolbox, not the one I mentioned above.

I use the List item expression to extract the data from a list, like so:

Then we clicking SEND I set the data source of the list item expression:
image

and then I save the json text that now contains the email addresses in a state:

and then I call the API (in this case update a google event), passing along the json:

1 Like

Thanks for the steps @renelonngren! Unfortunately, this requires some UI interaction in order to send the list as a string to the API Workflow endpoint (Note that I have already played around with Toolbox plugin to no avail). I would like a way to send a List of Things through the API Connector from the API Workflow.

Example:

  1. I curl the bubble endpoint (e.g. curl -X POST https://bubble.io/api/1.1./wf/endpoint)
  2. The endpoint will trigger the API Workflow and the workflow will send a List of Things as a JSON String Body (since there is no way to input as a list right now) to the API Connector API call endpoint

So with what I require, I cannot have a Bubble element be triggered by a user before I can get the List of Things as a string. Thank you for the help though!

One approach could be to build up the list one item at a time, using the text functions, storing as a text database field, and use recursive scheduled API workflow to add each item.

Another approach is to call an external API of your own creation, with separate lists for each field, and have it zipper them together to build up the list of fields.

Edit – oops I already answered with similar to this in this topic, post #9

Just wondering if this is still an issue?

I have a list of X recipients to send a message to. The current call is sending it as

{“contact”:“Contact_1,Contact_2,Contact_3…”, “message”:“body”}

This results in an error as the API I’m hitting cant handle an array for Contact.

I need to pass it as {“contact”:“contact_1”, “message”:“body”}, “contact”:“contact_2”, “message”:“body”}, and so on for the list

This is for a workflow.

@renelonngren I like your approach. I used it for my app, but I was faced with a problem I couldn’t solve. When there is a nested data structure, it is difficult to map them all together in one json. I then used the [jsoNest] plugin (jsoNest Plugin | Bubble). With this plugin I was able to create my own json containing data from many tables. It is very flexible. I could specify in great detail which field from which table I wanted in my json. Perhaps this approach is also easier for your case.

Hi there! While trying to make a correctly formated json with nested items to send to an API I also struggled with this issue for a bit, tried plugins but without success. Then I found the simplest, quickest solutions, with no plugins and really easy to grasp and implement.

Basically, I did the following:

  1. I the API call to make, I did not use any paramenters, just pasted in the raw json, and used it to initialize the call:

  2. In my workflow, the data is this call needed to be substituted by data from my workflow, for example “amount”, “currency”; etc. Well, those are inserted as dynamic values and done.

  3. When it came to inserting the dynamic list, in this case product information that the user has purchased, I needed to insert a “mini-json” with this list and the parameters between the after “Items” in the example above. So I created this mini-json using the “format as text” function, in a previous step and put it in a state (you could do it directly in the main json call as well though).
    That looked like this:
    image
    note that “item in cart” is a list of items in carts with several attributes.

So, when you click on “format as text”, you get this view where you can specify how to loop through your list:

And that’s it! Note, remember the delimiter, that needs to be not only “,” but “,” for some reason…

Hope this helps!

6 Likes

And that’s it! Note, remember the delimiter, that needs to be not only “,” but “,” for some reason…

Hi there!
What did you mean by the delimiter? Both appear to be the same.

Hi! Yes, it’s been a long time, so don’t remember the details.

But I believe the issue is that there are different kinds of “commas” ( , ) - they look the same to a humsn but not to the code.

I believe what I did was to find a plain .json document somewhere and then just copy/pasted it to get the rigth king of comma, that I then used as my delimiter.

Hope this helps!

1 Like