Pass JSON strings

Hi everyone,

I’ve been working on integrating the Uber Direct API into my Bubble marketplace app, and I’m facing several challenges related to timing, JSON formatting, and workflow sequencing especially when trying to dynamically generate and pass formatted JSON addresses for delivery quotes.

Goal:

I need to create a delivery quote by calling Uber’s API with properly formatted pickup_address and dropoff_address JSON strings (as required by Uber’s specs). These addresses must be constructed dynamically using data from the current cart’s seller and buyer.

What I’ve done so far:

-I created two backend workflows (generate_pickup_address_json and generate_dropoff_address_json) that return JSON strings using Return data from API.
-On the frontend, I created three custom events:
-Generate Pickup Address

  • Generate Dropoff Address
  • Continue Uber Quote (which calls the Uber API using the previously generated JSON).
    -The main workflow triggers all three in sequence.
  • Each custom event uses Schedule API Workflow and then attempts to set a custom state to the result of the backend workflow.

Problems I’ve encountered:

  1. Timing issues: Even though I’ve structured the workflow with custom events to ensure sequence, the pickup and dropoff JSON sometimes aren’t ready by the time the Uber API call is made , likely because Schedule API Workflow is asynchronous.
  2. Data not showing up: I’m using a group like Group Pickup JSON Helper and a text element inside it (Text Pickup JSON) to construct the JSON string visually. But in the custom event’s Return data from API action, I cannot reference Text Pickup JSON's text. Only Group Pickup JSON Helper's text appears, which doesn’t yield the value I expect.
  3. Bubble limitations: Bubble doesn’t allow mixing static and dynamic content directly in custom state values, and I can’t set state to Result of step X if that step is a custom event. This has made chaining logic really difficult.
  4. Lack of JSON preview/debugging: Even when I try to verify JSON strings in preview using text elements, they come up empty — possibly due to timing or because I can’t access the nested text element properly.

What I’ve tried:

  • Using text elements inside groups to build and preview JSON.
  • Returning data from backend and custom events.
  • Using custom events to control timing instead of sequential steps in a single workflow.
  • Making sure content-type in API responses is plain text.
  • Manually escaping JSON strings.
  • Using Bubble logs and inspector to trace workflow order and data.

What I need help with:

How can I reliably construct and pass JSON strings from dynamic address data for Uber Direct API in Bubble?
How can I return the contents of a specific text element (not the group) from a custom event?
Any best practices for chaining asynchronous backend workflows with frontend states and API calls?

I feel like I’m hitting a wall with Bubble’s limitations around dynamic text and workflow timing. If anyone has solved something similar or has a cleaner approach, I’d be super grateful for tips or examples.

Thanks!

This is false and mostly depend of your type. If you have set it to text for example, you can, but you can also use arbitrary text.
I think actually you have complex settings for settings that should be a lot more easier.
You also need to consider webhooks if you need asynchronous data.

Hello Jici,

You are right, my setting are too complex and it should be easier. The thing I need to do is format the pickup/dropoff address like Uber direct requires
( ```
pickup_address": “{"street_address": ["20 W 34th St", "Floor 2"],"state":"NY","city":"New York","zip_code":"10001","country":"US"}”,

“dropoff_address”: “{"street_address": ["285 Fulton St", ""],"state":"NY","city":"New York","zip_code":"10006","country":"US"}”


I have all the necessary user's data stored in my database, but I don't know how to pass it in that format to the Uber Direct API call 

Thank you for your help, one more time.

Share your API connector settings and also, why do you store it like that?

I don’t store it like that. I make the users put their address in the sign up form and then from that address I extract the city, state, country and zip code and store it in separate fields. The Uber Direct API requires the address to be in this format “dropoff_address”: “{“street_address”: [“285 Fulton St”, “”],“state”:“NY”,“city”:“New York”,“zip_code”:“10006”,“country”:“US”}” I don’t know how to build that string using how I have setup my database.

So in this case, You should A) remove double quotes around <pickup_address> and address> b) use abitrary text:formatted as json-safe (this will add double quotes and espace the JSON that you will create in the arbitrary text function). Create the JSON as requested from API in the arbitrary text for both fields.