Amol
Amol

Reputation: 481

Sonar API accessing Multiple Metrics

I am trying to use Sonar API for getting multiple metrices. When I am trying to get single Metric it is working fine but when giving a comma separated list it is returning blank response. E.g.

https://localhost/sonar/api/resources?format=json&metrics=tests [Works fine and returns response] https://localhost/sonar/api/resources?format=json&metrics=ncloc [Works fine and returns response]

https://tools.publicis.sapient.com/sonar/api/resources?format=json&metrics=ncloc,tests [Returns blank reponse i.e [] json ]

Am I doing it wrong. I have used comma separated list previously and it used to work fine. But now I am not able to figure out what is the issue

My Sonar version is 5.6

Upvotes: 0

Views: 1381

Answers (2)

Theolecodeur
Theolecodeur

Reputation: 1

for me api/resources works fine with multiples metrics, i call like that

https://localhost/sonar/api/resources?resource=[keyproject]&metrics=coverage,blocker_violations,critical_violations,sqale_debt_ratio

Upvotes: 0

Nicolas B.
Nicolas B.

Reputation: 7321

api/resources is deprecated. Its metrics parameter does accept comma-separated values (test it in a browser first, and careful with any reverse-proxy that may rewrite URLs), but you're better off using the most modern and up-to-date API: api/measures (documentation embedded in your SonarQube server), which also supports multiple values for metricKeys parameter.

Upvotes: 1

Related Questions