Skip to content
Community forum

sort_by in a /query body is ignored

SolvedSupero SupportSupero team asked

Common question, written up by the Supero team.

Sending this to POST /api/v1/crud/acme/query returns 200, but the products don't come back in price order:

json
{"type": "product", "match": {"in_stock": true}, "sort_by": "price", "sort_order": "asc"}
Link

1 answer

Accepted answer
Accepted answer

/query sorts with a sort array. sort_by and sort_order belong to GET list and POST /list-bulk. Each endpoint drops the other's spelling without an error, so you get default ordering and a 200.

json
{"type": "product", "match": {"in_stock": true}, "sort": [{"field": "price", "order": "asc"}]}

A bare string ("sort": "price") is accepted too, but it sorts descending by default. On GET list and list-bulk, sort_order treats any value other than "asc" as descending, and sort_by isn't checked against your schema, so a misspelt field name sorts on a missing key instead of failing.

Supero Platform teamSupero team answered
Link

Your answer

sort_by in a /query body is ignored | Supero Community