breeze Posted June 6, 2019 Report Posted June 6, 2019 Hi guys, Trying to wrap my head around one of the query fields here. I want to understand how to sort by a field with ASC / DESC. I am calling https://SERVER/api/services/getAllByClient.json And query fields: client_id = 1 status = active order_by = ???? The API docs give the example ['date_added' => 'DESC']. Whenever I pass this it just fails the whole request. For the record, the query string. https://SERVER/api/services/getAllByClient.json?client_id=1&status=active&order_by=['date_added' %3D> 'DESC'] What is to correct syntax for the order_by value? Thanks! Quote
0 activa Posted June 6, 2019 Report Posted June 6, 2019 Make all params inside a $vars array then use http_build_query() it will do the job for you. Anyway i think the result will be like order_by%5date_added%5=desc Tyson 1 Quote
0 Tyson Posted June 6, 2019 Report Posted June 6, 2019 Are you using the SDK from the API documentation? It will do this for you, but @activa is correct that you should pass your data through http_build_query() if you do it yourself. activa 1 Quote
Question
breeze
Hi guys,
Trying to wrap my head around one of the query fields here. I want to understand how to sort by a field with ASC / DESC.
I am calling https://SERVER/api/services/getAllByClient.json
And query fields:
client_id = 1
status = active
order_by = ????
The API docs give the example ['date_added' => 'DESC']. Whenever I pass this it just fails the whole request.
For the record, the query string.
https://SERVER/api/services/getAllByClient.json?client_id=1&status=active&order_by=['date_added' %3D> 'DESC']
What is to correct syntax for the order_by value?
Thanks!
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.