Forum Academy Marketplace Showcase Pricing Features

How to pass the list into API Connector?

Hi Everyone,

I am just trying to send the following list as the raw data into API Connector Plugin. How can I do it?

{
  "id": "cs_test_a",
  "data": [
    {
      "id": "price_1",
      "object": "price"
    },
    {
      "id": "price_2",
      "object": "price"
    },
    {
      "id": "price_3",
      "object": "price"
    }
  ]
}

I need to pass the “data” list into API.

This might help:

1 Like

@ lantzgould

Tried for custom object rather than list of strings, but it is not initialized. Getting error-

image

This is what I am trying-

See the product_list.

[{ "price": "price_1KfxSXSFwyATS3pY1JsMPpfr", "quantity": 8}, {"price": "price_1KfxRSSFwyATS3pYJac98KxO", "quantity": 2}]

Try with passing quantity as the string too, but same error.

Is this for a stripe checkout session? Or can you send me the API docs?

Yes, It is a stripe checkout session. Here is the doc link- Stripe API reference – Create a Session – curl

I’m not at my computer at the moment, but did you try formatting it like in the example in the post above? I’ll take a closer look when I’m back at my desk.

I know that’s a valid json you provided, but the api connector sucks sometimes and requires a little finesse.

Add :format as text after your list then format up the individual lines delimited by ,

image

Pass that into a parameter between the [ ]

1 Like

@NigelG

I am also trying the same, but getting the error:

How I am passing the data-

image

Error-

image

I am thinking is this something special with Stripe.

Your price and quantity must be between “quotes”.

It is almost always the formatting on the Bubble side. It is really annoying !

Start with hard coding a single item. Then make it dynamic. Then make it a list.

You need to make sure the array is formatted correctly, it will be very picky.

What does the API connector part look like? What Stripe API is this?

Tried that too, but still not working.

Yeah, I think some Stripe side issue. I have passed the hardcoded value still, Stripe send the same error.

I am trying to implement- Stripe API reference – Create a Session – curl with line items

But when I am passing the line_items as:

then it is working but it is no use, as I can’t predict the number of product user is purchasing.

1 Like

You may be better off adding the data items into the JSON Body. Rather than URL parameters.

But I think it probably wants to look like…

"line_items[0][price]"=1000,
"line_items[0][quantity]"=2,
"line_items[1][price]"=2000,
"line_items[1][quantity]"=1

Which is a bit weird !

So format as text “line_items[item # -1][price]”=x, “line_items[item # -1][quantity]”=y

@NigelG

Thanks for the suggestion. I think I have got it almost -

How can I replace the “0” with the current item index?

@NigelG @lantzgould any help?

You should be able to just highlight the 0, then use a dynamic expression…

I would’ve suggested what @NigelG had mentioned, but didn’t know if that was going to suite you. I too, had to structure in similar way.

@lantzgould
yeah, But I am not able to convert “0” to the dynamic expression.

I have tried using the javascript too but that also didn’t help, as I am not able to pass the index on "item #’ position.

Oh that is quite annoying!

Will have a think.

1 Like

@NigelG

I have figure out, thanks @m.bb

1 Like