Stupid Question #6218 - How to resolve IDs into names in Data API?

To all,

I’ve got my data apis set up and they work beautifully. However, I’m getting IDs for many of the fields. Rather than seeing Created by: 1667261302360x188833227624325220, I want to return Created by: some.one@domain.com or some other human readable information.

How exactly would I go about doing that? I’ve looked at creating a backend workflow to create my own API, but when I do return data from API, it returns the same thing as the data API.

Obviously, I’m missing something here. The Bubble docs on this area are nebulous at best.

So, to reiterate, how do I create a custom dataset to be sent to another system via API that has the ID fields resolved to a value of my choosing?

If you use the Workflow API - you can choose the fields and values of what is sent. So for example you can create a backend workflow endpoint that takes in a unique id as a Data Type and then return data as the action step and then you can return a thing and format all the fields the way you want. For the Data API you would just have to add nested API calls to use the unique id’s and get other values like a User’s email. There is no other way to return a type by another field than it’s unique id.

I’ve yet to find a good example of how to do this with the Workflow API though it feels like the direction I need to go. I’d appreciate any links, especially to video. The Bubble docs are quite sparse. I know how to set up an inbound API of which many videos have been made. Outbound APIs haven’t gotten the same level of love.

As for the Data API, if Bubble would implement $expand functionality in the Data API and make the API support OData.org standards, this would be extremely easy to do. I’ve built OData REST APIs before and it isn’t hard to do.

1 Like

Could make a new field in your dataset called something like ‘current_user_email’ and perform a do a search for User where unique id is current users unique id:first items email. Otherwise it’s just your typical relational data cross referencing uids.

Unless I missed what you’re asking.

Yeah, so how the URL for the Data API is example.com/api/1.1/obj/[datatype], instead for the Workflow API you would use example.com/api/1.1/wf/[backend workflow name].

this is how you can control what is returned per field in the workflow api

This is exactly what I needed! Thank you.

Ok, to close the loop on this, here’s what I did.

I wrapped my Search statement as you outlined above so that I had this structure returned, like the data API.

image

Next, I also had some long text fields so I used the formatted as JSON-safe modifier. I’ll probably put this on all text fields to ensure no issues. I like how it adds the double quotes for you.

image

To validate the output, I ran it through https://jsonlint.com/

2 Likes