Problems to set tags via API after Sonarqube update to 10.6

Hello Sonar team,

After upgrade Sonar from 9.9 to 10.6, I’ve noticed that I’m not able to set tags via API through the endpoint api/project_tags/set, I’ve been doing this since Aug/2023, and it’s working properly with the body:

    "project": $projectKey,
    "tags": $tag

but after the upgrade that’s the output of the response:

    "errors": [
            "msg": "The 'project' parameter is missing"

I’ve tested both variables $projectKey and $tag, and it’s all good, I can confirm that both values are ok.

Do you guys have any clue of what might going wrong?

For the record, my sonar instance is on-prem, I’ven executing the tagging script via Azure DevOps Pipeline with poweshell.

Thank you in advance.

Hey @paulo.silva!

I actually can’t get this to work on SonarQube v9.9 either. Can you give more details about how you generate the Web API call (specific commands, etc. would be great)

When I pass form-data it all works as expected. When I pass a raw JSON object, it doesn’t.

Hey @Colin, thanks for replying back,

So, this is the script that I’ve been using so far:

      $jsonObject = ConvertFrom-Json $env:SONARQUBE_SCANNER_PARAMS
      $sonarLogin = $jsonObject.{sonar.login}
      $sonarqubeUrl = ""
      $projectKey = "$(SonarqubeprojectKey)"
      $tags = "$(System.TeamProject)"

      $uri = "$sonarqubeUrl/api/project_tags/set"

      $headers = @{ 
        Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($sonarLogin + ":")))" 
      $body = @{
          project = $projectKey
          tags = $tags

          $webRequest = Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $body
          Write-Host $_.Exception.Response
          Write-Host "##vso[task.complete result=SucceededWithIssues;]"

I was working properly on Sonarqube v9.9, and just stopped after the upgrade to v10.6.


I used your script and had no problem against my SonarQube v10.6 instance.

Are you sure that, for example, $(SonarqubeprojectKey) is still resolving correctly? I get the same "The 'project' parameter is missing" message when the value is null as when it’s not included at all.

For example, when I add Write-Host $body, the console prints…

[tags, new] [project, org.sonarqube:sonar-scanner]

Hi @Colin,

I went through the release update and saw that sonar.login/sonar.password were deprecated, and just replace sonar.login by sonar.token and works like a charm.

I appreciate your time trying to help, have a great week ahead.

Thank you.

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