简体   繁体   English

无法使用 Nexus 3 REST API 和 CURL 下载

[英]Can't download using Nexus 3 REST API and CURL

I'm trying to download the latest snapshot dependency of a zip on Nexus 3 (version 3.22.1-02) from a command line using curl:我正在尝试使用 curl 从命令行下载 Nexus 3(版本 3.22.1-02)上 zip 的最新快照依赖项:

curl -u username:password -X GET "https://mynexusserver/service/rest/v1/search/assets/download?sort=version&repository=snapshotsrepo&maven.groupId=mygroup&maven.artefactId=myartefact&maven.extension=zip" -H "accept: application/json" -o myartefact.zip

This request is similar to this example: http://help.sonatype.com/repomanager3/rest-and-integration-api/search-api#SearchAPI-DownloadingtheLatestVersionofanAsset but no result is returned, myartefact.zip is empty.此请求与此示例类似: http://help.sonatype.com/repomanager3/rest-and-integration-api/search-api#SearchAPI-DownloadingtheLatestVersionofanAsset但没有返回结果,myartefact.zip 为空。

However with the same URL, my artefact is downloaded from a web browser or with gradle.但是,使用相同的 URL,我的人工制品是从 web 浏览器或 gradle 下载的。

With curl the following command line is working fine, returning the list of all snapshot versions of my artefact:使用 curl 时,以下命令行工作正常,返回我的人工制品的所有快照版本的列表:

curl -u username:password -X GET "https://mynexusserver/service/rest/v1/search/assets?sort=version&repository=snapshotsrepo&maven.groupId=mygroup&maven.artefactId=myartefact&maven.extension=zip" -H "accept: application/json" -o myartefact.zip

Downloading the artefact directly is working fine as well with a command line like:使用以下命令行直接下载人工制品也可以正常工作:

curl -u username:password "https://mynexusserver/repository/snapshotsrepo/mygroup/batchfactory/myversion-SNAPSHOT/myartefact-myversion-mytimestamp.zip" -H "accept: application/json" -o myartefact.zip

Verbose logs (-v option) show the artefact is found (I get HTTP/1.1 302 Found message) but nothing is downloaded.详细日志(-v 选项)显示找到了人工制品(我收到 HTTP/1.1 302 Found 消息),但没有下载任何内容。

Using wget doesn't work any better, I can't even query the list of snapshot version of the artefact.使用 wget 并没有更好的效果,我什至无法查询工件的快照版本列表。

Am I missing something?我错过了什么吗?

Thanks @Zeitounator, after adding "-L" the command line works fine.感谢@Zeitounator,添加“-L”后命令行工作正常。 Considering code 302 this feels obvious now...考虑到代码 302,这现在感觉很明显......

Nexus documentation should also probably be updated to add the "-L" option. Nexus 文档也应该更新以添加“-L”选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM