Kannan Sundararaj
Kannan Sundararaj

Reputation: 94

how to get all values of a patricular metrics in sonar REST api

I was able to get the list of projects(resources) from sonar REST API using the following java code

Sonar sonar = Sonar.create("wwww.example.com/sonar/api/resources?metrics=nloc");
ResourceQuery query = new ResourceQuery();
List resourceList = sonar.findAll(query);
for(Resource resource : resourceList){
  System.out.println(resource.getid()+":"+resource.getMetricIntValue("nloc"));
}

But this resulted in

1001:null
1002:null
1003:null
1004:null

Why is the lines of code value returning null?

Upvotes: 3

Views: 6688

Answers (1)

RustyTheBoyRobot
RustyTheBoyRobot

Reputation: 5945

The docs show the metrics parameter with a value of ncloc, not nloc. I think you've just got a typo.

Upvotes: 5

Related Questions