How do I include an array in a querystring in the API connector? (Stripe API)

I’m trying to include an array in a call to Stripe, which takes Content-type application/x-www-form-urlencoded (not JSON). I’ve set up my connector like so:

So you can see it all, for line_items I have [{price: “price_1MNRr6AsMDYPdgF3Dc2eaWos”, quantity: 5},]

When I try to initialize, I get the following error response:

Status code 400
{
  "error": {
    "message": "Invalid array",
    "param": "line_items",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_t8NczNlwZkXevB?t=1673311945",
    "type": "invalid_request_error"
  }
}

How do I properly format this array? I’ve tried all sorts of different versions including putting price in quotes, removing the comma at the end, etc.

And/or is there something else I’m doing wrong?

Thanks!

1 Like

Try:
parameter name:line_items[0].price, value: your price id
parameter name: line_items[0].quantity, value: 5

hi,
i have the same problem, did you find how to solve this?

Had the same issue and got it to work after some trial and error. You need to send price and quantity as individual parameters:
line_items[0][price]
line_items[0][quantity]

I find this so confusing though as this call allows you to send a list of prices. So how do you deal with the fact there will be a variable number of prices for the checkout? ie. customer 1 will have 4 items and customer 2 might have 6

Hi @alastair1
I have a similar use case with a different API. Instead of putting the parameters in fields I used the JSON body like this:


Then when I used the API as an action, I would send the list of ‘line items’ in my case then add the operator

:format as text

Then I would have the data for each ‘line item’ like this


It took a bit of trial and error to get the dynamic bit in the original call and the delimiter in the correct places.
Hope this helps

1 Like