Hi folks,
It seems that the v6 update introduced a bug in the API order_by=desc.
When a try to fetch the last tickets with https://{host}/api/v1/tickets?page=1&per_page=100&sort_by=number&order_by=desc
The result are not the last one, but the oldest one.
When I try https://{host}/api/v1/tickets?page=1&per_page=100&sort_by=number&order_by=asc
the result is exactly the same…
…I assume that order_by=desc does not work anymore…
Can anyone confirm that or help me anyway.
I implemented a workaround to fetch all result (with the pagination) and stop when no more result are returned, but it means that I have to fetch all tickets to find the newest one which is not ideal…
Thanks for you input.
Well, I had the same problem back in the days of 5.3, I found the order_by=desc solution to fetch the most recent tickets, and I recall that it worked like that…
So, are you telling me there is no way to list the tickets with the most recent on top ?
If so, what is the purpose of the order_by parameter ?
I’m confused… do I really need to fetch all tickets to find the most recent ones ?
What will be your approach to fetch the 100 most recent tickets ?
Thanks for any clarification.
When I see it correctly in the code this was not possible in the past for the normal ticket list endpoint, maybe you used before the “search” endpoint?
Yes, I used the /tickets/search endpoint.
I think I understand now…
I used the /tickets/search endpoint with an empty custom query (fetch all with &query=) and it worked with 5.3
With 6 I found that my implementation returned an empty result, I found out that the /tickets/search endpoint with an empty query (&query=) has not the same behavior that the 5.3, the results where empty if I pass en empty (fetch all) query. So I switched to /tickets endpoint which does not support the order_by.
When I try your example on my server http://{host}/api/v1/tickets/search?page=1&per_page=100&sort_by=number&order_by=desc&expand=1 I receive an empty result.
Is it normal, I mean I have at least 300 tickets ?
The result is not empty, but no tickets are returned {"tickets":[],"tickets_count":0,"assets":{}}
I tested a little bit with the ticket search endpoint. Normally it’s working fine, there is only one small different for the usage with ES or without (sql search).
With es the “query” parameter is needed, otherwise no result will returned, maybe there was also some missmatch on your side with the ES configuration.
Based on my testing, I guess you did not use Elasticsearch before, am I right?
Searching for tickets in the database without a query is working fine.
Searching for tickets in Elasticsearch without a query is returning an empty array.
The solution provided by @dominikklein is working fine here as well.
Thanks guys, that was it, I did install elasticsearch after migrating to Zammad 6.
My 5.3 install did not have elasticsearch.
I used the query=* like @dominikklein sugested, and everything works as intended.
Thanks a lot for your help.
…as a reward I published my Java Zammad connector under LGPL at