how do i create a repository through the REST API and was hoping someone could help me with the xml and curl script used.
相关问题
- Illegal to have multiple roots (start tag in epilo
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- Google Apps Script: testing doPost() with cURL
相关文章
- Creating XML Elements without namespace declaratio
- Get Attribute Value From Simple XML Using JQuery /
- Directly signing an Office Word document using XML
- Auto mirroring Nexus Proxy Repository
- When sending XML to JMS should I use TextMessage o
- Got ActiveRecord::AssociationTypeMismatch on model
- Multiple parameters in AngularJS $resource GET
- Fragment Content Overlaps Toolbar and Bottom Navig
TLDR
For Nexus3, use one of the example scripts from here to create your desired repository using the Script API.
Sonatype Nexus 3
The REST APIs have undergone (and I think are still undergoing) a bit of a revamp since version 2.
Repositories API
The current Repositories API is in BETA, and has only one endpoint to list repositories... so that won't work.
Script API
The Script API (v1, not BETA), allows tapping into the underlying Nexus libraries via Groovy. You can use this API to create and execute a script to create a repository.
e.g. Creating NPM repositories
Create a script to create NPM repositories, then execute the script.
Recommended reading:
Firstly, if you are curious on how to do these things, you can use this article by us at Sonatype on how to learn the Nexus Repository 2 REST API: http://www.sonatype.org/nexus/2015/01/26/learn-the-nexus-rest-api-automating-sonatype-nexus/
Secondly, here's an example one of our internal team members came up with:
This is a POST request to http://localhost:8081/nexus/service/local/repositories. You can use it like this with curl:
curl -H "Content-Type: application/json" -d @repo.json -u admin:admin123 http://localhost:8081/nexus/service/local/repositories
Here's some sample content for the "repo.json" file referenced by the above, which shows how to create a proxy Maven repository. Note that the payload for creating other types of repositories will be different, use the article above to find out what those are.