REST API - Finding asset by asset ID fails

rest
help

#1

Hi.

We have set up a webhook from our Nexus Repository Manager that calls another system every time a new asset is added to nexus, we would like to download the asset using the information contained in the webhook request.

A sample webhook request might look like this:

    {
    "timestamp":"2018-08-07T05:11:12.568+0000",
    "nodeId":"41C4E904-CCB7359A-3056945C-A04D87F5-EA169947",
    "initiator":"anonymous/192.168.1.1",
    "repositoryName":"releases",
    "action":"UPDATED",
    "asset":
        {
        "id":"abfd6260c292deb4873c42ce7fee0041",
        "format":"maven2",
        "name":"com/corp/enterprise/cr/schema/cr-common-schema/3.18/cr-common-schema-3.18-all.zip"
        }
    }

I am able to find the download link of the asset using the GAV in the following query:

https://nexus.corp.com/nexus/service/rest/beta/search/assets?group=com.corp.enterprise.cr.schema&name=cr-common-schema&version=3.18&maven.extension=zip

However, when I try to find the same asset using the asset id, generated by base 64 encoding this string:
releases:abfd6260c292deb4873c42ce7fee0041
which results in this string:
cmVsZWFzZXM6YWJmZDYyNjBjMjkyZGViNDg3M2M0MmNlN2ZlZTAwNDE

And then querying using this url:
https://nexus.corp.com/nexus/service/rest/beta/assets/cmVsZWFzZXM6YWJmZDYyNjBjMjkyZGViNDg3M2M0MmNlN2ZlZTAwNDE

I get the following response:
ERROR: (ID 2fa0ae24-7dd0-4b06-beda-12e11187d3af) java.lang.IllegalStateException: Timed out reading query result from queue 67b11e2 after 60 seconds

I do not have access to the corresponding server log at this time, but that can be acquired if needed.

So my question is this: Does anyone here have any clue what may be the issue here, and if yes, any tips to resolve this problem?

Regards
Andreas


#2

The request timed out. Which doesn’t tell us a whole lot, other than that the either the query is running slowly, or the request isn’t reaching Nexus Repo at all. Is the system it is running on meeting our requirements?

https://help.sonatype.com/display/NXRM3/System+Requirements


#3

Hi Andres,
Before going into the API details, if you’re simply trying to download the file, you should be able to construct the download URL directly from the webhook response; it contains the repository name and file name. Append those together along with your instance base url and you should be all set.

I am able to do this lookup successfully. So, a couple things come to mind. First, 3.13 moved the API to /v1/. So, your integrations will need to update their url when you upgrade. Second, this could be a bug in the older version. Third, this may be a copy/paste or forum issue, but there should be an equals sign (=) at the end of your encoded string. Even so, I get a HTTP 422 response code with an invalid encoded string, not a timeout issue.

If you do decide to continue down this route, we’ll need the full nexus.log to determine what might be going on.


#4

Hi, thanks for the replies.

After a little more research I discovered what @mworthington suggested, that I can download the file using the information I received in the webhook request, forming the url:

https://nexus.corp.com/nexus/repository/releases/com/corp/enterprise/cr/schema/cr-common-schema/3.18/cr-common-schema-3.18-all.zip

As this solves my problem, I will not be pursuing this issue any further.

Thank you for you feedback.