How to sort API expand fields ?


(Johann) #1

Hi All,

I built a REST API to get a list of books


http://localhost/api/web/v1/books

and get the details of each book by id


http://localhost/api/web/v1/book/7

In this last call, I added chapters in extra fields


http://localhost/api/web/v1/book/7?expand=chapters

but my chapters are sort in a bad way in the database :confused:

Do you have a solution to sort by default all related chapters ?

I tried




http://localhost/api/web/v1/book/7?expand=chapters&sort=title,number

http://localhost/api/web/v1/book/7?expand=chapters&sort=number



with no success…

Any help will be appreciated.

Thanks in advance.


(Chandrantwins) #2

you have to use like this … - for desc

[color=#303336]GET v1[/color][color=#303336]/[/color][color=#303336]users[/color][color=#303336]?[/color][color=#303336]sort[/color][color=#303336]=-[/color][color=#303336]priority[/color][color=#303336],[/color][color=#303336]status[/color]