How to write Get method Nexus Rest Api?

旧时模样 提交于 2019-12-21 06:04:09

问题


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


回答1:


Not sure what information you're looking for.

The REST API doco is availble here:

  • Core API
  • Lucene API

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'


来源:https://stackoverflow.com/questions/8513670/how-to-write-get-method-nexus-rest-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!