How to get quality profiles associated with sonar project or how to get projects associated with quality profile with quali

Must-share information (formatted with Markdown):

  • which versions are you using: SonarQube Community Edition Version 7.2.1 (build 14109)
  • what are you trying to achieve: I need to get a list of sonar projects which are associated with the specific quality profile using web-api. Or a list of quality profiles which associated with the specific sonar project using web-api.
  • what have you tried so far to achieve this: I tried to use /api/qualityprofiles/projects but failed. For example: https:///api/qualityprofiles/projects?key=AWwsrq3aku37rJwYfxkn, where AWwsrq3aku37rJwYfxkn - qualityprofile key which was returned /api/qualityprofiles/search. Sonar returns: {“results”:,“paging”:{“pageIndex”:1,“pageSize”:100,“total”:0},“more”:false}. But there are several Sonar projects which use such profile in Sonar UI.

Could you please help?

Hi,

i can confirm it doesn’t work as expected also with SQ 7.9.1 Enterprise.
Used the developer tools of my browser to see if Sonarqube server uses the same api call when
choosing the link for a non default quality profile at https://somesonarhost/profiles

Afterwards i used exactly the same api call

https://somesonarhost/api/qualityprofiles/projects?key=........&page=1

but the response is

{“results”:,“paging”:{“pageIndex”:1,“pageSize”:100,“total”:0},“more”:false}

Gilbert

Just wanted to use the endpoint lately and find this post now. So… affected as well in version 7.9.3 (Developer edition) and a bit disappointed because this seems to be the only (offered) way of filtering projects for the quality profile.

IMHO that is a bug and needs @MODERNWEB_MW: Can you help to advise on how to catch a devs attention here?

next to that this thread is related to Quality Profile of Project where they found a workaround.

Hi,

When I try it for a non-default profile, I get the expected result:

https://next.sonarqube.com/sonarqube/api/qualityprofiles/projects?key=AW0gGvRy3I_RMAUpkH0j&page=1

->

{
"results": [
{
"uuid": "AW0abn1qGHw5MqdAqloE",
"id": "AW0abn1qGHw5MqdAqloE",
"key": "com.sonarsource:citytour2019-java",
"name": "City Tour - Java project",
"selected": true
}
],
"paging": {
"pageIndex": 1,
"pageSize": 100,
"total": 1
},
"more": false
}

It is indeed a bit harder to go the other direction.

 
Ann