Forum Academy Marketplace Showcase Pricing Features

Bubble API Endpoint - Define parameters

Hi there,

I have a quick question on how to set up the bubble API endpoint.

I have a JSON payload like so.

{
	"person": [
		{
			"name": "John Smith",
			"age": 25
		},
		{
			"name": "Jane Doe",
			"age": 69
		}
	]
}

How do I set up the bubble API end point to process this payload?

Both the API endpoint “person” and thing “person” are available in the open bubble app.

API endpoint -->

“person” thing -->

The “person” thing is simple and contains only two fields - name and age.

The JSON payload contains two persons and that data is in an array.

I’m having a bit of problem in defining the bubble API endpoint parameters correctly. For example, should the key type be “person” - since the data should update the “person” thing or “text”?

Right now, I’m using Postman to test this and all my calls have resulted in errors.

Any help would be much appreciated?

If possible, it would be great if you can update the end point correctly :slight_smile:

Cheers!

The parameters are what get sent to Bubble with the request, so it shouldn’t be a nested object. Lets say you have a workflow person that creates a person, you’d do.

parameters: ‘name’, text and ‘age’, number

and then the request will be something like

forumapp3.bubbleapps.io/version-test/api/1.0/wf/person?name=jane&age=69&api_token=XX, etc.

Does that makes sense?

Hey, @emmanuel I try this but I cant do it. I cant configure the api call.

@emmanuel thanks for your feedback.

I think I understand what you are saying.

If I’m updating a “thing” through the API endpoint, it should be as parameters.

One follow up question - how do I recover the data in the JSON payload so that I can use it in bubble. It looks an API endpoint is not the correct solution for this. Is there any other feature of the Bubble platform I should be using?

I’m guessing that this is a common use case for any bubble App that depends on an external source for data.

The external source is going to format the data as they want (JSON array or nested parameters) and my bubble app needs to process and recover the data. How do we do this?

Cheers!

I think the API connector is what you’re looking for, if I understand your situation

@emmanuel

Yes, I think I need to use the API connector.

I tried it but I’m running into some challenges.

The API connector set up requires a call to an external API (say UBER), and bubble parses the response. This works very well. In the UBER example, using the API connector I’m able to get the product listing for a location like so:

{
  "products": [
    {
      "capacity": 4,
      "product_id": "6450cc0f-4d39-4473-8632-1e2c2049fefe",
      "price_details": {
        "service_fees": [
          {
            "fee": 1.3,
            "name": "Booking fee"
          }
        ],
        "cost_per_minute": 0.24,
        "distance_unit": "mile",
        "minimum": 4.3,
        "cost_per_distance": 1.35,
        "base": 1.35,
        "cancellation_fee": 5,
        "currency_code": "USD"
      },
      "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png",
      "shared": false,
      "short_description": "uberX",
      "display_name": "uberX",
      "description": "The low-cost Uber"
    },
    {
      "capacity": 2,
      "product_id": "c97ddc01-42ae-4761-8fa6-cd14955477b4",
      "price_details": null,
      "image": "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png",
      "shared": true,
      "short_description": "uberPOOL",
      "display_name": "uberPOOL",
      "description": "Share the ride, split the cost."
    }    
  ]
} 

The API connector is able to parse this JSON array and the nested data it contains. I can display the information in a repeating group. This is working amazingly well.

The challenge I’m facing is this:

Based on my limited understanding, for the API connector to work, I need to initiate a call from bubble to on an external service. The use case I have ----> based on some processes running on an external service, the external service sends a payload to my bubble App. The call is not initiated from bubble. I want to expose a bubble “webhook” to catch the payload and process it.

Is there a way to use the API connector for this? Or is there something else that can be used?

Apologies for the rather long post. I feel I’m very close to figuring this one out but not quite yet.

1 Like

If it’s a webhook, then it’s the API workflow. You should need to find a way not to have nested objects in the request to Bubble then.

Yes, I have in parallel been exploring this option as well.

I am testing out Zapier and other similar (no code) tools but I was hoping to avoid this. This creates a middle man, whose only role is flattening nested objects and sending them as separate calls. And in the testing I have done so far, Zapier also seems a bit limited in this area. I was hoping to avoid code :slight_smile:

I’m a bit confused as why one part of bubble (API connector) is able to process complex data formats whereas another part (API workflow) is very limited.

Simply put, it would great if we can get the processing capabilities of the API connector and set it up like as one would a webhook on Zapier. Set up the API connector as a webhook, and once it receives the payload, the process would be the same as it is now for the API connector -i.e., map the payload fields to their type and use it.

In the meantime, my search continues . . .:pensive:

@emmanuel - I found another service that I’m using to flatten the JSON the way bubble wants it :slight_smile:

This is a bit frustrating though, to use an another service to do something bubble can do.

I hope that this will fixed soon?

1 Like

I too am facing a similar issue - and prefer not to use an additional extra (paid) service to flatten the json before sending it to the API workflow. I wonder if there is a creative way to solve (or workaround) this with Bubble. Any recommendations from Bubble experts?

1 Like

@madras did you figure out how to uber webhook?