user1587852
user1587852

Reputation: 1617

Retrieving Project Metrics using Rest API and Timemachine from SonarQube

I'm trying to retrieve projects metrics using the REST Api. Therefore I first query the projects using "/api/projects/index". Afterwards I retrieve the metrics using "/api/metrics/search". Both works fine. And I result with:

Now I wanted to retrieve a projects metrics. Therefore I use the following URL: https://MYHOST/sonarqube/api/timemachine/index?resource=35476&metric=10019&fromDateTime=2010-12-25T23:59:59+0100&toDateTime=2018-12-25T23:59:59+0100

There the server retruns only: [{"cols":[],"cells":[]}]

This surprices me, because when I enter the WebInterface of sonar for the project, I can see numbers. I tried some other metrics, however all ended with the same result. What am I doing wrong?

Upvotes: 1

Views: 1321

Answers (1)

G. Ann - SonarSource Team
G. Ann - SonarSource Team

Reputation: 22804

You didn't mention server version, so I'll assume the latest: 5.2.

I got the same result for a bare query (http://nemo.sonarqube.org/api/timemachine/index), and for a query which specified resource but not metrics (http://nemo.sonarqube.org/api/timemachine/index?resource=org.sonarsource.sonarqube%3Asonarqube).

So I'm guessing there's a problem with either your resource or metric id. Try using the keys (com.test&%3ATestProject, and complexity) instead.

And yes, the ids you got back from the other web services should work here, but what's meant by "id" can be a little... ah... variable from service to service to service.

Upvotes: 1

Related Questions