ankur1
March 22, 2022, 3:27am
1
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.
ankur1
March 22, 2022, 4:22am
3
@ lantzgould
Tried for custom object rather than list of strings, but it is not initialized. Getting error-
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?
ankur1
March 22, 2022, 5:27am
5
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.
NigelG
March 22, 2022, 9:06am
7
Add :format as text after your list then format up the individual lines delimited by ,
Pass that into a parameter between the
1 Like
ankur1
March 22, 2022, 10:13am
8
@NigelG
I am also trying the same, but getting the error:
How I am passing the data-
Error -
I am thinking is this something special with Stripe.
1 Like
Your price and quantity must be between “quotes”.
1 Like
NigelG
March 22, 2022, 10:18am
10
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?
ankur1
March 22, 2022, 10:26am
11
Tried that too, but still not working.
ankur1
March 22, 2022, 10:28am
12
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
ankur1
March 22, 2022, 10:30am
13
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
NigelG
March 22, 2022, 10:41am
14
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
ankur1
March 22, 2022, 11:26am
15
@NigelG
Thanks for the suggestion. I think I have got it almost -
How can I replace the “0” with the current item index?
ankur1
March 23, 2022, 2:28am
16
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.
ankur1
March 23, 2022, 2:46am
18
@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.
NigelG
March 23, 2022, 10:52am
19
Oh that is quite annoying!
Will have a think.
1 Like
ankur1
March 23, 2022, 4:40pm
20
@NigelG
I have figure out, thanks @m.bb
try var array = ["search for cartItems: each items priceid join with ", " "];
1 Like