How to write Get method Nexus Rest Api?

2019-03-31 08:08发布

I have groupId, artifactId and version. How do i write a GET request using Nexus Rest API in order to get further artifact description?

标签: api rest get nexus
1条回答
萌系小妹纸
2楼-- · 2019-03-31 08:39

Not sure what information you're looking for.

The REST API doco is availble here:

Examples

Obtain the repository id

You're starting with: groupId, artifactId, version:

$ curl --silent 'http://repository.sonatype.org/service/local/lucene/search?g=log4j&a=log4j&v=1.2.16' | grep repositoryId
<repositoryId>central-proxy</repositoryId>
<repositoryId>apache-staging</repositoryId>
<repositoryId>central-proxy</repositoryId>
<repositoryId>apache-staging</repositoryId>

The repositoryId is mandatory in other API calls

Artifact resolution info

$ curl --silent 'http://repository.sonatype.org/service/local/artifact/maven/resolve?r=central-proxy&g=log4j&a=log4j&v=1.2.16' 
<artifact-resolution>
  <data>
    <presentLocally>true</presentLocally>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
    <extension>jar</extension>
    <snapshot>false</snapshot>
    <snapshotBuildNumber>0</snapshotBuildNumber>
    <snapshotTimeStamp>0</snapshotTimeStamp>
    <sha1>7999a63bfccbc7c247a9aea10d83d4272bd492c6</sha1>
    <repositoryPath>/log4j/log4j/1.2.16/log4j-1.2.16.jar</repositoryPath>
  </data>

Retrieve the POM

$ curl --silent 'http://repository.sonatype.org/service/local/artifact/maven?r=central-proxy&g=log4j&a=log4j&v=1.2.16'

Retrieve the jar

$ curl --silent 'http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=1.2.16'
查看更多
登录 后发表回答