Configuration API

Configuration API

The following endpoints are used to access the complete Nexus Repository configuration as well as a complete listing of assets found in each repository.

Export Configuration

This endpoint is used to retrieve the configuration of your Nexus Repository instance as JSON file. The types of entities returned are different depending on Nexus Repository version and edition supported by the license.

GET /v1/configuration

Requires the nexus:settings:read permission.

Note
This endpoint requires the request header to be set. Requests that do not include this header will return HTTP 400 (Bad Request).

Example:

curl -v -u admin:admin123 \  
-H "X-Nexus-Migration-Protocol-Version: 1" \  
"http://localhost:8081/service/rest/v1/configuration"

Upload Repository Configuration

This endpoint may be used to import configuration from one Nexus Repository instance to another instance.

PUT /v1/configuration

Requires the nexus:settings:write permission.

Get Assets

This endpoint lists the complete asset metadata in JSON format.

GET /v1/configuration/assets

Requires read permission for the repository asset.

The following query parameters are supported:

Results are in descending order using the timestamp of when the asset was created.

Import Asset

For importing a single asset and its specific attributes. Use this endpoint to import artifacts from one Nexus Repository instance to another.

POST /v1/configuration/assets/{repositoryName}/import

Requires write privileges to the destination repository. This endpoint responses with a HTTP status.

Table 1. Path Parameters

Parameter Description
repositoryName Path parameter denoting which repository to import the asset into.

Table 2. Required Headers

Header Description
X-Nexus-Migration-Protocol-Version: 1 Required migration protocol version header. Requests without this header return HTTP 400 (Bad Request).
Content-Type: multipart/form-data Required content type for multipart asset uploads.

The multipart request requires the following named files to be included in the request:

Table 3. Multipart Form Fields

Field Field Description
asset Yes The binary asset file to upload to the repository.
attributes No A JSON document containing metadata associated with the asset. This endpoint expects content compatible with the response returned by the Get Assets endpoint.

Attributes JSON Example:

{
  "path": "/com/example/artifact/1.0/artifact-1.0.jar",
  "contentType": "application/java-archive",
  "lastModified": "2024-01-15T10:30:00.000Z",
  "lastDownloaded": "2024-01-15T10:30:00.000Z",
  "blobCreated": "2024-01-15T10:30:00.000Z",
  "uploader": "admin",
  "uploaderIp": "192.168.1.100",
  "fileSize": 12345
}

Example Request:

curl -X POST "https://nexus.example.com/service/rest/v1/configuration/assets/my-repo/import" \
  -H "X-Nexus-Migration-Protocol-Version: 1" \
  -H "Content-Type: multipart/form-data" \
  -u admin:password \
  -F "asset=@/path/to/artifact.jar" \
  -F 'attributes={"path":"/com/example/artifact/1.0/artifact-1.0.jar","contentType":"application/java-archive"}'

Example Response:

HTTP/1.1 201 Created

The response contains an AssetXO JSON document describing the imported asset.

Note