Bubble API Help

I am trying to figure out how to utilize the Bubble API

I’ve successfully set up a Get Call. What I am doing is using two Bubble Applications of mine to try and get them to use the API.

Application 1 has the data and is set up to Enable the Data API. Application 2 has the API Connector Plugin with the calls set up.

What I am struggling with now is trying to set up a Post. I want to take data created in Application 2 and send it to Application 1 where it will create a new entry in Application 1 database.

In Application 2 I have set up a Post call and have initialized it successfully. My Application 1 has the create via API checked off.

What I don’t understand is how to SEND the data from Application 2 to Application 1…my initial thought is that there would be a workflow action that I could trigger with the press of a button once the data has been entered into the input elements on Application 2, however, I see nothing that would allow me to send the data.

How am I suppose to send the data from Application 2 to Application 1?

Do I need to set up some workflow in Application 1 to accept the data?

The reference does a minimal job of explaining the process and it is completely void of any indication on how to send the data by way of initializing the request.

/version-test/api/1.1/obj/Social-Security-Numbers

The reference has some more useful information, but it is down a little further, under Data API (hopefully the link takes you to the correct spot on the page).

Maybe the Bubble App Connector is more useful than the API Connector in this case?

Otherwise, I mostly build APIs that have some sort of workflow behind it. That means that I build a workflow in the Backend Workflows page which I always found easier to troubleshoot.

Speaking of troubleshooting, try using Postman or Hoppscotch (née Postwoman) might provide you more useful errors than Bubble.

1 Like

Thanks I will have to play around with the App Connector.

When you build APIs with workflows behind it, how are you triggering the workflow from another app?

Basically, I can’t figure out how to trigger a Post API call to send the data.

As per usual my limited capacity for ‘give up’ pushed me to dig deeper into the forum with more and more refined searches…finally came up with a search phrase ‘trigger api post’ (sometimes finding the right phrase might be the most difficult part) and came across this post

I had previously set everything up correct for the Post call as the Initialize Call was creating data in the other apps DB…the only difference of not finding a workflow action that could be triggered to trigger the POST call was the “Use as” portion at the top next to the name…that needs to be set to Action to get a workflow action associated with the call rather than Data.

Also, need to uncheck Private next to the key values to enable dynamic values to be sent.

1 Like

Do you NEED to have a REST API (the Data API) here?

If this is just for “internal” use then it will be simpler to use either the App Connector or a Backend workflow (this is the “trigger workflow” option that you mention).

If this is to distribute to third parties, who will interact with your App via API…

Your API connector in 1 will “just” do a POST to …

https://xxxxx.bubbleapps.io/version-test/api/1.1/obj/xxxtable

With Authorization Bearer xxxxxxx in the Header

And in the Body…

{
“field”:“aaaaaa”,
“otherfiield”:“bbbbb”
etc
}

Set it up in Postman first. This does not run a “workflow” on App 2. It inserts directly into the Bubble database.

Hi @NigelG

At this stage I am really just trying to explore more of the feature. I have a few potential use cases for it, but nothing that I am implementing at the moment. Having a better understanding of its functionality will definitely help in preparing some future projects that would make use of it.

I will have to explore the App Connector a bit more.

In regards to the Backend Workflow…is there a way to set up a backend workflow in Application 1 and have Application 2 trigger without the use of the App Connector or Api Connector?

I believe the Authorization Bearer is this? I have below in App 1 setup the API Token

Screen Shot 2021-03-28 at 10.38.43 PM

And then in App 2 use this token in the header of my calls

Screen Shot 2021-03-28 at 10.38.56 PM

Is this the Authorization Bearer? I’ve seen other threads reference the authorization bearer and in my limited use of API calls to 3rd party services such as stripe have seen the need to add ‘bearer’ into the headers and other times not needed to.

So with what I have shown in the screen shot, not 100% confident that this is the authorization bearer, or if it is, that I have set it up properly.

Also, in the event that I were to distribute to third parties who will interact with my App via API is there a way to dynamically create a new Authorization Bearer, or would it necessitate the creation via the applications ‘Settings - API’ tab in the editor?

I’ve seen this Postman referenced previously and just checked out the site.

Are the majority of reasons to set it up in Postman first to avoid any ‘mishaps’ from affecting the application whose database would be modified via the API, or does Postman provide for some helpful clues on how to troubleshoot when setting up APIs that a non-technical person like myself would benefit from the service?

Cheers

Matt

Well, you could use Zapier or something like that. But you still need to hook it up the the workflow API in App 1 even then.

In Key you need Authorization in Value you have Bearer 1130dsjakdjlsa etc etc

Postman tends to provide some more helpful clues as to what is going on.

Postman has got a lot more complicated now, so https://hoppscotch.io/ is a better alternative now if you haven’t used Postman from its simpler days.

An excellent question. I don’t know if you can do it via a workflow.

Thank you @NigelG for the insights…as always very helpful and informative.

I do have one other question regarding the privacy policies.

I currently have them setup like this only for my testing purposes as I am unsure of exactly how best to restrict access via Privacy and API.

If I were to be providing an Authorization Bearer to third parties for access, is there a need to create a limiting access privacy policy or would having the ‘Everyone Else’ policy enable the create/delete/modify via API be okay since the Authorization Bearer acts as ‘access token’?

Do you generally have any tips or insights into some best practices regarding setting up the conditionals for a privacy policy?

I’m kind of thinking that to setup a privacy policy to limit access I would need to have the user be signed up to my app that provides the API to make use of the conditional statement since it is limited to ‘current user’ and ‘this datatype’.