How to get a response related to the comment_line in version v25.3.0.104237

I have a SONARQUBE container installed in the docker-desktop
I was using the Community Edition v10.7 (96327) version, but it became NOLONGER ACTIVE

This time, I run a new SONARQUBE container, and the version is CommunityBuild v25.3.0.104237.

I can’t get the results from the API response.

In v10.7

curl -X GET "http://sonarqube:9000/api/measures/component_tree?additionalFields=metrics&ps=500&asc=true&s=qualifier%2Cname&p=1&component=gradle_project%3Asrc&metricKeys=comment_lines&strategy=all" \  -H "Accept: application/json" | jq

{
      "key": "gradle_project:src/main/java/seable.java",
      "name": "seable.java",
      "qualifier": "FIL",
      "path": "src/main/java/seable.java",
      "language": "java",
      "measures": [
        {
          "metric": "comment_lines",
          "value": "4"
        }
      ]
    }

But v25.3.0.104237

curl -X GET "http://sonarqube2:9000/api/measures/component_tree?additionalFields=metrics&ps=500&asc=true&s=qualifier%2Cname&p=1&component=gradle_project%3Asrc&metricKeys=comment_lines&strategy=all" \  -H "Accept: application/json" | jq
{
  "errors": [
    {
      "msg": "Insufficient privileges"
    }
  ]
}

I gave token value, but I still didn’t get a response.

curl -X GET "http://sonarqube2:9000/api/measures/component_tree?additionalFields=metrics&ps=500&asc=true&s=qualifier%2Cname&p=1&component=gradle_project%3Asrc&metricKeys=comment_lines&strategy=all" \
    -H "Authorization: Bearer sqp_af3g2r38f3jer0fsadf57d0c2e04bc248f30fd832jf9" | jq
{
  "errors": [
    {
      "msg": "Insufficient privileges"
    }
  ]
}

But I get the other API response

curl -s -X GET "http://sonarqube2:9000/api/issues/search?components=gradle_project&s=FILE_LINE&impactSoftwareQualities=SECURITY&issueStatuses=CONFIRMED,OPEN&severities=MAJOR,CRITICAL,BLOCKER" \
     -H "Authorization: Bearer sqp_af3g2r38f3jer0fsadf57d0c2e04bc248f30fd832jf9" \
     -H "Accept: application/json" | jq

{
      "key": "gradle_project:src/main/java/mapTest.java",
      "enabled": true,
      "qualifier": "UTS",
      "name": "mapTest.java",
      "longName": "src/main/java/mapTest.java",
      "path": "src/main/java/mapTest.java"
    }
  ],
  "facets": []

Please tell me how to get a response related to the comment in version v25.3.0.104237

Hi,

That endpoint has always required Browse permission on the project in question. At a guess, the gradle_project stopped being public / accessible by anonymous sometime around the upgrade?

You’ll need to provide a token from a user with permissions on the project.

 
HTH,
Ann

1 Like

Thank you for answer.
I thought about that, too
I gave permission shown in the picture.
But it’s same

Hi,

Since the project is public, everyone has Browse. Can you successfully use the Measures tab of the project?

 
Ann

1 Like

Thank you for answer.
I can response about the issue.

jenkins@fc7a019dea36:/$ curl -s -X GET "http://sonarqube2:9000/api/issues/search?components=gradle_project&s=FILE_LINE&impactSoftwareQualities=SECURITY&issueStatuses=CONFIRMED,OPEN&severities=MAJOR,CRITICAL,BLOCKER" \
     -H "Authorization: Bearer sqp_af3g2r38f3jer0fsadf57d0c2e04bc248f30fd832jf9" \
     -H "Accept: application/json" | jq
{
  "total": 36,
  "p": 1,
  "ps": 100,
  "paging": {
    "pageIndex": 1,
    "pageSize": 100,
    "total": 36
  },
  "effortTotal": 0,
  "issues": [
    {
      "key": "5c1b64cd-ac8c-4ca8-9425-2b4006956784",
      "rule": "findsecbugs:PREDICTABLE_RANDOM",
      "severity": "MAJOR",
      "component": "gradle_project:src/test/java/subscriberTest.java",
      "project": "gradle_project",
      "line": 58,
      "hash": "56bda0249bca20986ea6110738dec1fe",
      "textRange": {
        "startLine": 58,
        "endLine": 58,
        "startOffset": 0,
        "endOffset": 91
      },
      "flows": [],
      "status": "OPEN",

So I don’t think it’s a matter of permission
I think endpoint is a problem, I want to know anothers
(/api/measures/component_tree?additionalFields=metrics&ps=500&asc=true&s=qualifier%2Cname&p=1&component=gradle_project%3Asrc&metricKeys=comment_lines&strategy=all)

Hi,

My question remains:

 
Ann

1 Like


Yes, I can confirm that.

Hi,

Thanks for that confirmation. The fix, then, is to use the APIs that the UI uses.

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.

 
Ann

1 Like

Thank you for your answer.!
It helped me a lot.