Suitable SonarQube api for specific json output

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) : Data Center Edition Version 9.9.1
  • how is SonarQube deployed: On AWS VM
  • what are you trying to achieve
    I need SonarQube api to get json response like below for my internal application

Example:

{
“task”: {
“id”: “XXXXXXXXXXXXXXXXXXX”,
“type”: “REPORT”,
“componentId”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,
“componentKey”: “test-demo”,
“componentName”: “test-demo”,
“componentQualifier”: “TRK”,
“analysisId”: “xxxxxxxxxxxxxxxxxx”,
“status”: “SUCCESS”,
“submittedAt”: “2024-04-30T10:28:51+0000”,
“submitterLogin”: “karjagi-shivarajakumar-XXXXXX”,
“startedAt”: “2024-04-30T10:28:52+0000”,
“executedAt”: “2024-04-30T10:28:56+0000”,
“executionTimeMs”: 2794,
“logs”: false,
“hasScannerContext”: true,
“organization”: “default-organization”,
“branch”: “main”,
“branchType”: “BRANCH”,
“warningCount”: 0,
“critical”: 7,
“high”: 9,
“medium”: 235,
“low”: 958,
“warnings”:
}
}

I tried to hit SonarQube API (https://mycomapanyserver/api/ce/task?id=<task_id>) and got below json responace but here i am not getting security hotspot information (high, medium,low and warning) like above example response

{
“task”: {
“id”: “xxxxxxxxxxxxxxxx”,
“type”: “REPORT”,
“componentId”: “XXXXXXXXXXXXXXXX”,
“componentKey”: “test-demo”,
“componentName”: “test-demo”,
“componentQualifier”: “TRK”,
“analysisId”: “XXXXXXXXXXXXXXXXXXXX”,
“status”: “SUCCESS”,
“submittedAt”: “2024-04-30T10:28:51+0000”,
“submitterLogin”: “karjagi-shivarajakumar-XXXXXX”,
“startedAt”: “2024-04-30T10:28:52+0000”,
“executedAt”: “2024-04-30T10:28:56+0000”,
“executionTimeMs”: 3448,
“hasScannerContext”: true,
“branch”: “main”,
“branchType”: “BRANCH”,
“warningCount”: 1,
“warnings”: ,
“nodeName”: “sonarqube-sonarqube-dce-app-7f95c98884-dlhp4”
}
}

what is the specific api should i hit to get json response as shown in example response?

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Where did you see the example you’re trying to replicate?

Was it perhaps from a SonarQube instance on the latest version? SonarQube 9.9.* is never going to return high, medium, low metrics because those are not Security Hotspot-related. Instead they are issue metrics in the new quality model in more recent SonarQube versions.

 
HTH,
Ann

Hi Ann,

Thanks for your response…

The sample response i got it from internal documents and trying replicate the same
and i am using 9.9.* version

when i logged in to console i can see issue metrics like Blocker, critical, major, minor, info and i can see High, medium …on security hotspot tab so that’s why i got confused

any way what is the specific api to get it ?

Hi,

Have you tried this via the UI? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

You may also find this guide helpful.

 
HTH,
Ann

Thank you Ann…It’s really helpful thanks a ton