Consume SonarQube Data

Hi Team,
Hope you are doing well.

I’m using SonarQube Version: * Community Edition* Version 7.9.1 (build 27448)

I want to build a application that displays some SonarQube data and stats . For achieve this goal, i need to communicate with database or API to retrieve the data.
To retrieve information for example: How many issues or vulnerabilities some project has.
Thanks in advance.

Hi @hermanmaleiane,

Your SonarQube version is out of date and unsupported: you should upgrade ASAP to SonarQube 8.9 LTS.

For your use case, you should use SonarQube API. Access its documentation via http(s)://<your_sonarqube_server>/web_api. You can also access it from the link in the footer of your SonarQube website.

Cheers,
Daniel

Hi @Daniel_Meppiel.
Thank you.

I’m getting the below error while trying to retrieve the list of projects.
https://sonar-host/api/projects/search
My Goal is to retrieve all analyzed projects with his quality gates. i want to build a separated dashboard.

Hi @hermanmaleiane ,

You have a problem with the way you have written the URL into postman. It is adding a “linefeed” (%0A) character at the end of the URL. If you remove that character, it will work.

You may also test using curl.

Cheers,
Daniel

Hi @Daniel_Meppiel . That works. Thank you so much.
I have one last question if you don’t mind.

I’m not sure which API i can use to retrieve this kind of information (In the screenshot) for each project.

Hi @hermanmaleiane ,

Please explore the API documentation or alternatively, inspect the SonarQube website itself with your web browser, the Network section. The SonarQube UI uses the API itself to obtain most if not all data you can see on it. So you can spot which methods are being used and learn from it for your own implementation.

It seems like GET api/measures/component could help you.

Much appreciated @Daniel_Meppiel.
Thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.