How to get results from Sonatype Nexus REST API in JSON format
1 answer
As an example with curl, here is a call to get a list of repositories
curl http://localhost:8081/nexus/service/local/repositories
which will give you formatted XML output. To get the same in JSON format, you simply edit the HTTP request header like this
curl -H "Accept: application/json" http://localhost:8081/nexus/service/local/repositories
Potentially you want to add credentials and specify the content type (especially if you are sending the JSON download as part of the request). You can also go to POST ..
curl -X GET -u admin:admin123 -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8081/nexus/service/local/repositories
+7
source to share