Forum Academy Marketplace Showcase Pricing Features

[New Feature] API Connector improvements

Hello,

We just deployed an improvement for the API connector that lets you define some dynamic parts in the URL (an the body for a POST request). If you enter part of the body between brackets ("[xx]"), Bubble will automatically

  1. identify this as a parameter
  2. replace it in run mode / initialization call by the value.

It’ll work as parameters for the body of the request, if you mark them private that means they can’t be modified at the call level, while if they’re not private you can change them at the action or the Get data from API level.

This implementation will make that users don’t have to deal with URLs, etc, and it more powerful in the long run.

As usual, let us know if you hit issues through a bug report.

15 Likes

Hi @emmanuel , this update seem to fix my issue. Thanks! :slight_smile:

1 Like

Hi Emmanuel,

I have an API that works with the following inserted into the body:

{“Test2”:“Johnnyboy”}

Again, this works.

But when I use the [] I don’t understand the syntax here. How should I write this?

I’ve put in:
{"[Test2]"}.

I get:

Can you please provide the appropriate syntax for me? I have tried filling in the value, filling in with quotes, removing the “Johnnyboy” from the body, and 40 other variations. With no luck. Can you please explain how this call should be written when using the [] feature?

Thanks for the help,
P

1 Like

What are you trying to send? Generally, the key wouldn’t change, but the value, so it should be

{“key”:[value]}

@emmanuel does the value substitution in the body handle escaping backslash and double quotes? Also, does it handle arrays?

Thanks!

That’s a good question (and good point…). Turns out [] isn’t great for body, but works great for the URL. We’ll change that to <> in the body, that should be safer and you’ll still be able to use arrays, etc.

In terms of quotes, it’s your responsibility to make it work. What we do is just replace the by hello (if the value is hello).

We’ll push the change today

OK. Sure would be nice if you guys handled the JSON encoding… :slight_smile:

What do you mean by JSON encoding?

let’s say I have a POST api with expected body:

{
“nested_object”: {
“key1”: <value1>,
“key2”: <value2>
}
}

If value1 was tes\t" - <value1> would be replaced with “test\t”"
If value2 was an array, <value2> would be replaced with [“elem1”, “elem2”]

You can work around both of these things - the former with find&replace and the latter with the join with expression, but it’s clunky.

1 Like

Was just about to post a need for this! Thanks!

Can anyone share an example of a use case for this feature?

https://reference.promisepay.com/#deposit-funds

Some of the calls in this API requires the new feature above to be in place.

Example:

POST /wallet_accounts/:id/deposit

“:id” is a dynamic parameter but in the old API connector, it would not have been possible to make this call (using dynamic ":id"s)

Issue with the new syntax “”. The API connectors don’t seem to be picking the value. Even in the Modify Call action the values are not being fed in. Any fix?

Also, what happens to all the earlier established API connectors? Do they auto adjust or do we have change all of them manually?

I got the same issue here. The <> brackets create a new parameter but then it doesn’t pick up the new value.

The earlier established API connectors didn’t change. Or at least not for me. :confused:

Can you file a bug report so that we can look into it?

Done. Also, anyway is it possible to do limited release of new features? Over the past few days there had been 2 updates on this i think, and we had to redo all initializations for API calls. Was pretty frustrating given we had a lot of these calls. :slight_smile:

2 Likes

Bubble, can you please make a tutorial about connecting twitter external API, so I can POST, GET on behalf of my users. I love the tutorial you made on how to use the Etsy API but it wasn’t enough to make me understand how to POST using Twitter API because it’s more complex.

Thank you!

For Twitter you cannot use the API connector, as they use Oauth1. We have a plugin that integrate twitter. Not all calls are there but it’s a start…

That makes sense! I hope you guys add the POST call soon. And thank you for the fast response!

Was this resolved?