CURL request to upload a single file and also delete a repo

257 views
Skip to first unread message

Abika

unread,
Jun 15, 2018, 3:50:49 AM6/15/18
to Nexus Users
Hi guys,

I am trying to write a script that will upload the files to maven staging (https://oss.sonatype.org/). I have successfully uploaded a new repository by using curl request and also listed all the repositories available. 

I need help on dropping a repository and uploading files to an existing repo. (since I am using unconventional way of using curl request to do this rather than using maven plugin, I am unable to find relevant content in the net. I found the REST API documentation for the "localhost:8081" which will be in the local and I am trying to do the same to the oss.sonatype.org ).

If anybody has done this before or have at least tried this, please throw some light on this for me. 

Any guidance is welcome.

Regards,
Abika

Rich Seddon

unread,
Jun 15, 2018, 2:32:56 PM6/15/18
to Nexus Users
In Nexus Repo 2.x the easiest way to discover the REST API calls is to perform the action in the UI and watch the HTTP traffic using your browser's debug tools;



The endpoint to use for dropping staging repositories is "/service/local/staging/bulk/drop".

Using a JSON payload this would be something like this:

curl -v -u user:password -H "Content-Type: application/json" -d @drop.json -X POST http://localhost:8081/nexus/service/local/staging/bulk/drop

With a payload like this:

{
    "data": {
        "description": "some description",
        "stagedRepositoryIds": ["abc-1002"]
    }
}

Abika

unread,
Jun 15, 2018, 6:57:44 PM6/15/18
to Nexus Users
Thanks for the suggestion rich, I have gone through the contents in the net about uploading the maven repo to the localhost:8081. But the rest API for the oss.sonatype.org is different. I need to know about the rest API curl request for the oss.sonatype.org. Please give any ideas about that.

Regards,
Abika

Rich Seddon

unread,
Jun 15, 2018, 7:04:28 PM6/15/18
to Nexus Users
The "localhost" URL's are just an example.  The oss.sonatype.org server is running Nexus 2, so the REST API's are the same.

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/535f7846-54c6-4fec-a2e3-be6925834721%40glists.sonatype.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.

Abika

unread,
Jun 15, 2018, 7:27:18 PM6/15/18
to Nexus Users
Hi Rich,

Thats awesome! Thanks for letting me know about this. And also just now I tried deleting a repo using the API URL for the localhost ...it didnt work. I got "< HTTP/1.1 301 Moved Permanently" and I could still find the repo in the UI and also by listing all the repositories using the rest API hit.

Regards,
Abika
Reply all
Reply to author
Forward
0 new messages