GET contains nested fields. How do I specify these in an API endpoint?

Hi,

I’m POSTing data to a bubble endpoint. It works in postman and returns a dataset that has ‘nested’ fields (profile: …):

{
“id”: “676133161”,
“quantity”: 1,
“profile”: {
_ “first_name”: “Polly”,_
_ “last_name”: “Pocket”,_
_ “email”: “ms_p@gmail.com”,_
}
},
“event_id”: “26835849749”,
“order_id”: “536707466”,
“ticket_class_id”: “52933328”
}

I’m able to get the ‘non-nested’ fields: event_id, order_id, etc… to populate into my database using the API workflow, but the ‘nested’ fields profile:first_name, last_name & email don’t populate.

If I make profile_email a required field the POST fails and returns an error that the field profile_email doesn’t exist.

How have others handled these ‘nested’ json fields in the API workflow?

1 Like

hi there,

I have a posted a similar and related question on the forum.

So far I have not got a definitive answer.

Will message if I figure it out. Do let me know if you find a way make it work.

Cheers!

2 Likes

What do you mean by not populated? Are you talking about the request parameters or the returned data?

For request parameters we don’t support sending objects (except a bubble thing represented by its ID)., so that may be the limitation you’re hitting.

Hi Emmanuel -

By ‘not populated’, I mean that the ‘nested’ fields don’t populate in the database.

I have an API workflow that is accepting the POST data below.
When the API is triggered, the non-nested fields, “event_id”, “id” populate in the database. Wonderful. But the nested fields “profile.first_name”,
“profile.last_name”, and “profile.email” don’t populate in the database.

{
“id”: “676133161”,
“event_id”: 1,
“profile”: {
_ “first_name”: “Polly”,_
_ “last_name”: “Pocket”,_
_ “email”: “ms_p@gmail.com”,_
}

If, in the endpoint, I make “profile.email” a required field (non-optional), the POST fails and the error message states that “profile.email” is not found. This hints to me, that I’m not specifying the nested fields profile.first_name, profile.email…correctly.

What is the correct syntax for these nested JSON fields?

Will do.

Figured it out!

I’m now using Zapier to flatten the nested JSON fields. The workflow now looks like EventBrite (webhook) → Zapier (webhook and mini-etl) → Bubble (API endpoint)

Here’s some screenshots on how it works in Zapier.

The zap specifies the fields that will be received by the Bubble Endpoint. Now you have a Zap.


Set up Bubble Endpoint

That’s it.

2 Likes

@sridharan.s Did you ever figure out how to capture nested fields into database without going through zapier first?

I haven’t tried. Once we got it set-up with zapier, we stopped refining it.

Best of luck!

@emmanuel Is zapier still the best way to accomplish this or can the Bubble API endpoints now capture the data directly from these nested parameters in the webhook?

1 Like

@stephencharles, I believe the new API Connector can handle nested parameters. Haven’t set it up myself, but pretty sure that’s one of the key new capabilities with the updated API Connector.

Yes it does, we shouldn’t be losing information from JSON objects now.

We are still losing information from child objects within the nested JSON sent to API endpoint.

I was talking about JSON as response for the API Connector, not as a body of a request to the API workflow (it’s unfortunate all these concepts have API in it…).

Hey @stephencharles

If your interested we are trying to get this co-sponsorship off the ground. It will help you get nested objects