How to pass the list into API Connector?

Hi Ankur1, did you manage to create a session with a dynamic amount of line_items ? Can you share the syntax of your solution, please?

Yes,

This is how I am passing the dynamic data-

image

Thanks for your reply !
In the meantime, I baked myself a solution for that same problem that only relies on Bubble’s expressions, not other plugin or javascript required.

Here’s how:
My case here concerns the line items object on Stripe Checkout Sessions but it’s exactly the same process for other list of objects that must be passed as url-encoded.

in the API Connector, I use JSON Dynamic Value to set the query string entirely that I can then modify in the workflow interface.

In the workflow I use a list that contains Basket Items (with Product, Price, Quantity) and format it as text as shown below to create the query string.

I hope this approach can be useful to some of you guys. :slight_smile:
Happy Bubbling

5 Likes

A little tricky but I was able to build on @axel.duheme to get the final solution. If you need to get the line item # to fill out the I had to do a search for the order items that were created and then count all of the ones which had a smaller created date then the item -1 to get the 0,1,2,3,4 for the .

You can see an example here

I also attached the order item filtering here

Not sure if this is the best way but it worked for me!

Also, if anyone needs. Here is the text that goes into the <line_items>

line_items[price_data][currency]=USD&line_items[quantity]=1&line_items[price_data][unit_amount]=100&line_items[price_data][tax_behavior]=exclusive&line_items[price_data][product_data][name]=Test

2 Likes

But how do I initialize first in the api connector? I am having the same issue with Mindbody api

@thePrince in the api connector you need to pass the complete json as the variable.

@ankur1 @axel.duheme I am not familiar with the syntax used in the body with the ampersands (&). It doesn’t look like JSON to me. Is this more a Bubble syntax? That said, it looks pretty intuitive what it is supposed to do. I just want to what language that is and if there’s references I can research. Thank you.

@cinji18 its kind of separator. Its a way to send the querystring in the request.