Unable to get latest version when using api

i am trying to use the download api to get the latest version of a release but it looks like the artifact that i am getting is the first on the list and not the latest. nexus version is OSS 3.25.1-04 .

curl -v -X GET “[http://localhost/service/rest/v1/search/assets/download?sort=version&repository=maven-releases&group=com.test&name=demo” -H “accept: application/json” -H"Authorization: Basic **********"

according the doc ( Search API) it should retrieve the latest. does anyone encountered the same issue?

You should specify the direction of the sort

hey thanks , but according to the doc it should already retrieve the latest.

You can download the latest version of an asset by using the “sort=version”

anyway i tried many formats [sort=±version , sort=version± , sort=version&direction=desc etc… ] and none of them worked .

do you know what is the correct format ?
thanks in advance !

We are running version 3.38.0-01 and using the search API we get another version on each request.
It looks like it is paging the versions and returning the next on each request.

Is there a variable to only and always return the latest snapshot version?

Thanks

We too are having problems with this. Ditto Wouter’s version, we are also on v3.38.0-01 and I have also tried all the combinations of path params that Daniel mentioned with no success. It always pulls the first version built. I recall seeing a bug report that this had been fixed in an earlier version, but it appears to have crept back in? Any chance you can help us with this? It has caused some lost effort in determining that our deployment process had pulled the oldest version and not the newest. Appreciate any insight.

Agree with Bob, I have the same problem, also for Sonatype Nexus Repository ManagerOSS 3.38.0-01.

Probably this is the report on the earlier issue [NEXUS-24601] Search API sorting doesn't work - Sonatype JIRA (found 3.25, fixed in 3.26).

In out test example, we had a bunch of 16 snapshot versions of the same artifact (all of them generated within one day). My observation (with simply sort=version as mentioned in the API for getting the latest version) called in a loop most of the time (18 out of 20 times) gave the artifact #13 (not #16, as I wold have needed). Once I got #11.

Any support on that highly appreciated!