API connector only works when parameter is same as value initialized

Hi all, running into an error i’ve not seen before.

When I call the API connector from a backend workflow and specify the parameter, it only works when the parameter in workflow = the parameter I used to initialize the call.

Any idea what I’m doing wrong?

I initialize the call by manually entering the value for parameter ‘ids’.

When I call the API connector in the backend workflow, I specify the ‘ids’ parameter, but it only works when it is specified with the parameter I used to initialize the API connector, in this example ‘ruby’. If I change the parameter in the workflow to something else, e.g ‘ethereum’ I don’t get any response from the API connector.

To add a little more color with log results.

In the workflow, I save the result from from the API connector in the next step under ‘test_1’.

You can see in the logs, when parameter is set the same as the parameter used to initialize the API connector (e.g ‘ruby’) ‘test_1’ gets a value, but when I change it (e.g ‘ethereum’) it does not.

Try putting the parameters in the url like so:

https://api.coingecko.com/api/v3/simple/price?ids=[ids]&vs_currencies=[vs_currencies]

Thanks for suggestion @lantzgould, but it seems to be the same result.

One interesting thing I noticed. Even through I specify the ‘vs_currencies’ parameter as ‘USD’ it never shows up in the logs…

The set up (how it was initialized):

When passing ‘ruby’ as a parameter in workflow it works:

But when passing ‘ethereum’ , it doesnt:

For some reason it works if you use Option Sets to show in the logs… Might be worth reaching out to Bubble, but for your sanity try this:

image

image

hmmm, that’s interesting and unexpected behavior.

My initial reaction is that Option Sets would’t be a sustainable solution for my app since, even though ‘currencies’ is static with ‘USD’, ‘ids’ is dynamic (it can be any cryptocurrency, of which there are hundreds / thousands that get added to frequently).

It seems like there should be a better solution for this since I expected this to be a standard use case for the API connector.

I noticed this same bug yesterday. What the heck is going on?

That’s really odd - I’m reaching out to support now.

Did you find a solution?

I’m only doing testing now, so i don’t need the dynamic values. It seems like my old API calls aren’t broken though. No solution yet

1 Like

Yeah, I meant that this isn’t normal behavior and to reach out to support. Was just trying to find a workaround in the interim for ya.

Let us know if you hear back from support.

1 Like

Will do.

Thanks @lantzgould

You forgot to check “private”. See your first screenshot.

Hey @keith

The reason “private” isn’t checked is because the ‘ids’ parameter needs to be set in the backend workflow - it’s dynamic.

If I set as “private” I don’t believe I can set it from the backend workflow, unless I misunderstood how that works?

Got a reply from Bubble support, see below.

I’m not well versed enough in APIs to know whether this is poor API design by Coingecko or Bubble not being robust enough.

**Response from bubble:
"It appears that the primary issue is with the how the API provider is returning data to Bubble.

For example, when getting the exchange rate between Ruby and USD the API will return the following:
{
“ruby”: {
“usd”: 0.12428
}
}

Because the API is using the name of currency as a “key” in the JSON returned, Bubble will only recognize the returned value as valid if that key matches what was there when the API was initialized.

Bubble expects that key values are not dynamic so the API would need to return a result like the example below for it to work with the API connector in its current form.
{
“exchange”: {
“currency”: “ruby”,
“compare_to”: “usd”,
“price”: 0.12428
}
}

Currently, the only work around for this would be to either use a different API provider or create a separate call for each currency that you may use."