Reputation: 21
I tried to use the GET method of api/metrics to retrieve a JSON to use for my program, but the documentation lack to describe all the parameter to use in the requestUrl.
for example in for my program I find, using the Google Chrome console, that the requestUrl is this one:
is it possible to find a more detailed documentation or the way I try to solve my problem is not the correct one?
Upvotes: 1
Views: 11010
Reputation: 495
In response to your question how to call from a outside comment:
If you want to call the SonarQube Web Service API from a Java program you can use the Apache HTTP Client:
public static void main(String[] args) throws ClientProtocolException, IOException {
HttpGet httpGet = new HttpGet("http://localhost:9000/api/resources?metrics=lines");
try(CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpGet);) {
System.out.println(response.getStatusLine());
HttpEntity entity = response.getEntity();
System.out.println(EntityUtils.toString(entity));
}
}
In this case it prints all projects on SonarQube and additionaly the metric "lines". You can add multiple metrics to the list, separated by a comma:
"http://localhost:9000/api/resources?metrics=lines,blocker_violations"
Upvotes: 1
Reputation: 4706
Just add &format=json
to the parameters.
See http://docs.sonarqube.org/display/SONARQUBE43/Web+Service+API#WebServiceAPI-ResponseFormats
Upvotes: 3