Get Sonar Issues Report From WebAPI

I’m using SonarQube Enterprise 8.7 and I would like to know if it’s possible to get an issues report by querying the SonarQube web API?

I know the HTML report feature doesn’t work anymore and the only way to get reports per each build might be through querying the web API but I’m not sure how to go about it.

At the moment, I’m trying this bit of code

curl -u foo:bar,ncloc,line

But it errors with {"errors":[{"msg":"The 'component' parameter is missing"}]

Ideally, what I’m after is to just get the lines of code, the number of bugs, vulnerabilities, and Code smells in each run/scan.

Something like this

But by querying the web API.

Is this possible, please?

Also I hear that Sonar Version 8.9 has the option to download reports as PDF, is this option available per project or per analysis?

Thank you.

Hi Tee,

I’ll give you a good general answer: the SonarQube UI is also built atop the web API, so use your browser’s developer tools to explore which calls we’re making as that page is rendered, then imitate that.

It’s available specifically and only for the Security Reports tab, per branch of each project (i.e. always the latest analysis of that branch).