Nested array in Stripe API call? (can't use JSON body)

I’m trying to setup a Stripe customer portal configuration via the API Connector but I’ve hit a roadblock. I’m able to create arrays using the bubble parameters but I’m not sure if nested arrays are possible. Here’s what the request is supposed to look like:

{
  "features": {
    "subscription_update": {
      "enabled": "true",
      "products": [
        {
          "product": "prod_ONpjCeXlzM5OCi",
          "prices": ["price_1Nb445I2rfN87qVGKpiCIGNB", "price_1Nb445I2rfN87qVGTUN8HqmZ"]
        },
        {
          "product": "prod_ONpiD7eytdVl4h",
          "prices": ["price_1Nb42sI2rfN87qVGZTrgJmvh", "price_1Nb42sI2rfN87qVGOQdTuSwz"]
        }
      ],
      "default_allowed_updates": {
        "quantity": "1",
        "price": "price_1Nb445I2rfN87qVGKpiCIGNB"
      }
    }
  },
  "business_profile": {
    "privacy_policy_url": "https://site.com/",
    "terms_of_service_url": "https://site.com/"
  }
}

(I’ve added two products here but I think one is enough)

I’m currently using these parameters in my API call:
features[subscription_update][products][product][0]
features[subscription_update][products][prices][0]
features[subscription_update][products][prices][1]

But the problem is, those arrays are supposed to sit inside a “features[subscription_update][products][0]” array, and I don’t see a way to do that in Bubble.

This is the error I keep getting:

There’s a lot of way, but I have created a plugin for that (not owned by @thimo)

Take a json and serialize to url

Can can you share your API connector setting? This is also possible to do this in Vanilla Bubble

Thanks, will check it out in a bit.

Here’s my API connector setup:

Your structure is not correct. The array is at products level, not at the end
should probably be something like
features[subscription_update][products][0][product]
features[subscription_update][products][0][prices][]
(prices is also an array, but don’t need a number)

@Thimo Can you upgrade the plugin version to 4 (node18) because it doesn’t work anymore actually

1 Like

@duracel when @thimo will have updated the plugin version, the output will look like this (tested in my version)

features[subscription_update][enabled]=true&features[subscription_update][products][0][product]=prod_ONpjCeXlzM5OCi&features[subscription_update][products][0][prices][]=price_1Nb445I2rfN87qVGKpiCIGNB&features[subscription_update][products][0][prices][]=price_1Nb445I2rfN87qVGTUN8HqmZ&features[subscription_update][products][1][product]=prod_ONpiD7eytdVl4h&features[subscription_update][products][1][prices][]=price_1Nb42sI2rfN87qVGZTrgJmvh&features[subscription_update][products][1][prices][]=price_1Nb42sI2rfN87qVGOQdTuSwz&features[subscription_update][default_allowed_updates][quantity]=1&features[subscription_update][default_allowed_updates][price]=price_1Nb445I2rfN87qVGKpiCIGNB&business_profile[privacy_policy_url]=https://site.com/&business_profile[terms_of_service_url]=https://site.com/

I personnally prefer to encode in JSON and convert it after (with Bubble encoded as text and json-safe function, this make this really simple to use with the plugin)

1 Like

Putting the array at the product level worked, thanks @Jici :pray:

1 Like