API Connector | Is there a way to manually configure the API call to allow for multiple values to the same key

I have an api which has the same key and I need to provide multiple values.

For eg : The key foo needs to have two values - value1 and value2 . Essentially the call would be - /api/v1?foo=value1&foo=value2

In the current format, the plugin doesn’t pick this up and selects only one of the value.

Do you have docs to reference.

Sounds like @sudsy has some good suggestions below

1 Like

Perhaps one of the following will work:

  • /api/v1?foo[]=value1&foo[]=value2
  • /api/v1?foo[0]=value1&foo[1]=value2
  • /api/v1?foo=value1,value2

Those are the more common ways to pass an array via query string. The correct approach will depend on the framework used to implement the API. The second option works for me with Stripe’s API.

Yes. This is the API - Retrieving assets

I want to use - asset_contract_addresses

Thank you for the reply. None of these work for my use-case. :slightly_frowning_face: :

You can set the first foo and use join with &foo=

It could be that Bubble is de-duping the params before they’re sent - i.e. it might require each param to be unique. Did you actually try the second approach I suggested?

Yes, I tried all three of your approaches.

I am getting a 404 - {"asset_contract_addresses[0]":["extra fields not permitted"],"asset_contract_addresses[1]":["extra fields not permitted"]}

Well first off, the URL in your initial post suggests you’re not actually hitting the endpoint because it doesn’t have assets in it. The proper endpoint should look like…

https://api.opensea.io/api/v1/assets

…and then add the question mark and try the various query string configurations…

https://api.opensea.io/api/v1/assets?asset_contract_addresses=0x1...&asset_contract_addresses=0x2...

https://api.opensea.io/api/v1/assets?asset_contract_addresses[0]=0x1...&asset_contract_addresses[1]=0x2...

https://api.opensea.io/api/v1/assets?asset_contract_addresses[]=0x1...&asset_contract_addresses[]=0x2...

https://api.opensea.io/api/v1/assets?asset_contract_addresses=0x1...,0x2...

@Jici _- Tried joining with &foo=. That doesn’t seem to be working as well.

@sudsy - Totally yes. I just added the required part for simplicity in the question. I am using the whole URL when I am implementing it. Let me summarize so that you can replicate the issue.

What is want to query - https://api.opensea.io/api/v1/assets?owner=0x528e48bcb500518e78c1c8cccfc7275ed945cfb5&asset_contract_addresses=0xfa932d5cbbdc8f6ed6d96cc6513153afa9b7487c&asset_contract_addresses=0xc729ce9bf1030fbb639849a96fa8bbd013680b64

^ You can copy-paste this in your browser to see the response.

What I have tried in Bubble -

  1. Adding two parameters with the same key and different values
  2. All the suggestions that @sudsy gave in the thread above.
  3. Joining with &foo (as @Jici above mentioned)

#1 and #3 leads to an empty return. #2 returns a 404, saying extra fields are not permitted.

One more question - Is there a way I can find the exact GET call Bubble is making?

I think I just found the solution. I was using @sudsy 's solution in the Parameter section. I tried it directly in the API call section and it worked.

Sharing a screenshot for documentation.

Thank you everyone for the help!! Love the very prompt and helpful comments :slight_smile:

1 Like

FWIW, you don’t need 0 and 1 there. You can use whatever key name you want - e.g. Addr 1 and Addr 2.

The square brackets in that context do not indicate array indexes. They’re just a Bubble construct for delimiting tokens that are replaced with the values of the corresponding keys below.

For future reference, always post a screenshot when you can. It often provides essential context that helps others help you.

3 Likes