Sorting bubble database API call

Hello, I am unable to get the sorting to work, this is the constraints used in the call -

[{
“key”: “computerhostname”,
“constraint_type”: “equals”,
“value”: “DESKTOP-LALA3R3”
},
{
“sort_field”: “registrationdate_date”,
descending”: “false”
}
]

The results returned with such query -

Switching descending to ‘true’ returns the results in the exact same order.
I have tested it with other fields as ‘Modified date’ and bubbles native ‘Created Date’ - no dice :roll_eyes:

Is it something obvious that I am missing?
Thank you!

Oooookay, re-read the docs for the third time and now it’s all clear.
Sorting should not be used in constraints but the url itself!
So now the working query is-

https ://website.com/api/1.1/obj/registrations?api_token=token&constraints={JsonConstraintsVariable}&sort_field=Modified%20Date&descending=true

:robot:

Glad you got that working.

I personally use the sort as a body parameter and the method of using true false works fine with parameter key set to descending

If you were doing that and having issues, I’d recommend sending a Bug report to get Bubble to fix it.

1 Like