Unable to find Web Api to get the issues since last analysis

sonarqube

(Mudabbir Pasha ) #1

Hi,

I am new to SonarQube,
Here I found two Web API’s

  1. To get list of all projects.
    api/projects/index?format=json

2.To get total number of issues in last 1 month
api/issues/search?projectKeys=(project name)&createdInLast=1m&severities=CRITICAL,BLOCKER,MAJOR

I need help in finding the Web Api to get the total number of issues since last analysis
or
A web Api to get the date of last analysis for a particular project.
So that I can get the number of issues from last analysis date.

I tried finding the above api but without any success,
Any tip will be of great help.

Thanks in advance.


(Stas Vilchik) #2

Hi,

Using the api/project_analyses/search endpoint, you can get the list of project analyses. Then you can use api/issues/search?createdAfter=<some date> to get the list of issues (and their total number) created after a particular date.


(Mudabbir Pasha ) #3

Thanks,

  1. api/issues/search?createdAfter=
    this api I had come across
    But could not find api to find the date when the project was last analysed.

and
this api/project_analyses/search?projectKeys=(project_name)
this api is not available for me I guess. I get an error "The Page you were looking for doesn’t exist"


(Emre Dundar) #4

Hi Mudabbir,

You can try this api call:
http://localhost:9000/api/issues/search?statuses=OPEN&sinceLeakPeriod=true&componentKeys={your_project_key}

You have a wrong word (“projectKeys”) on your link. Please change it with “project”:
http://localhost:9000/api/project_analyses/search?project={your_project_key}


(Stas Vilchik) #5

You can try this api call:
http://localhost:9000/api/issues/search?statuses=OPEN&sinceLeakPeriod=true&componentKeys={your_project_key}

This is true only if you set your project leak period to “since previous analysis”.


(Stas Vilchik) #6

this api is not available for me I guess. I get an error “The Page you were looking for doesn’t exist”

The api was introduced in SonarQube 6.3. Do you use an older version?


(Mudabbir Pasha ) #7

‘This is true only if you set your project leak period to “since previous analysis”.’

how can I set project leak period to “since previous analysis”


(Stas Vilchik) #8

My bad, this option is not available since SonarQube 6.7 (SONAR-9142).