How to access nested fields in Bubble database type to filter with 'constraints' parameter through the GET API call

Hey everyone! Does Bubble have a special way/notation to access nested fields in JSON? In the internal (call to our own database) API call, I want to filter users on the email. Here is the call’s URL: https://myapp.com/version-[version]/api/1.1/obj/user?constraints=[{“key”:“authentication.email.email”,“constraint_type”:“equals”,“value”:“[email protected]”}]. Neither ‘dot’ notation neither square brackets (“authentication[‘email’][‘email’]”), two most popular notations, works. Natively, the user’s email is nested in the ‘authentication’ field. Here is what the Bubble database JSON looks like:
“authentication”: {
“email”: {
“email”: “[email protected]”,
“email_confirmed”: null
}
},

I didn’t know the data API accepted constraints.

I would give it a try by building a workflow and exposing that. :thinking: wait, can a backend workflow read query parameters?

Hoping someone better informed can throw their 2cents here.

Is your API request rate lower enough to handle this via regular Workflow API? Then you can structure the response the way you want

and yes @rico.trevisan if it’s triggered as a GET it should read the query parameters

TIL I learned that it does indeed: Data API requests - Bubble Docs

But apparently I can’t search by email?!?

privacy rules are ok.

Is it because it’s nested inside authentication.email.email?

Might as well keep talking to myself out loud. Found the answer here: Search by email with Data API? - #8 by zaki.r

use "key":"_all" instead. 😵‍💫

1 Like

Yes, there is a workaround by creating a backend workflow that returns filtered user. But the goal was to set constraints in the API call, to filter objects directly

That is the problem I’m talking about. Quite often I’m using filtering in API calls for complex conditions. You can replace 40 conditions with one properly filtered API call. But ‘email’ is nested… how can I access it?