Creating repositories, groups etc. via REST API in Nexus 3

Hi there,

I want to know if I can leverage the REST API as it was in nexus 2 so that I can create repositories, perform configuration in the repository etc. remotely. By googling I wasn’t yet able to find information. Help, anyone?

Fred

Hey Fred,

Check out the documentation for all the API options here: REST and Integration API

Let us know if you need anymore help around these.

Cheers,

Nick

Hi Nick,

thanks for responding. I can’t find API for changing user credentials, or admin password, or creating new repositories and so on programmatically. Is this no longer possible with nexus 3?

Thanks,
Fred

You can use the scripting API for those use cases. See here:

https://help.sonatype.com/display/NXRM3/Script+API

These links will also be of use:

Nexus 3 Groovy Script development environment setup
https://help.sonatype.com/display/NXRM3/Examples
Groovy: Close those transactions, or else…

Hi,

Can someone help me with the api to add nexus hosted repo to group (Public repo)?

I need to run curl through bash script.

You could use this url path to do a POST with nexus oss 3
/service/rest/beta/repositories/nuget/proxy

Body
{
“name”: “internal”,
“online”: true,
“storage”: {
“blobStoreName”: “default”,
“strictContentTypeValidation”: true
},
“cleanup”: {
“policyNames”: “weekly-cleanup”
},
“proxy”: {
“remoteUrl”: “https://registry.npmjs.org”,
“contentMaxAge”: 1440,
“metadataMaxAge”: 1440
},
“negativeCache”: {
“enabled”: false,
“timeToLive”: 1440
},
“httpClient”: {
“blocked”: false,
“autoBlock”: false,
“connection”: {
“retries”: 0,
“userAgentSuffix”: “string”,
“timeout”: 60,
“enableCircularRedirects”: false,
“enableCookies”: false
},
“authentication”: {
“type”: “username”,
“username”: “string”,
“ntlmHost”: “string”,
“ntlmDomain”: “string”
}
},
“routingRule”: “string”,
“nugetProxy”: {
“queryCacheItemMaxAge”: “mixed”
}
}

1 Like

Can you pls let me know how to query baseversion? I am not seeing any components for base version in REST Response… Pls help me

Is it possible that rest api in nexus 3 or any version accepts artifacts other than maven artifacts

We have something like this:
Url is nexus/service/local/repositories - only accepts maven artifact in nexus 2. Wanted to check if rest api url in nexus higher versions can directly accepts zip file not maven artifacts.

Curl -H " content-type: application/json" -d @repo.json -u username password http://bar.t-dev.corp.****/nexus/service/local/repositories nexus