Web-api settings/set keeps throwing errors that values must be provided

Hello

I am trying to script the creation of sonarqube projects.

i want to set exclusions. i tried this

https://sonarqube.xxxxx/api/settings/set?key=sonar.coverage.exclusions&component=sys.CAMS.CAMS.REACT&values=**%SF*

also tried this

https://sonarqube.xxxxx/api/settings/set?key=sonar.coverage.exclusions&component=sys.CAMS.CAMS.REACT&value=**%SF*

Either one of them throws this error.
Invoke-RestMethod : {“errors”:[{“msg”:“Either \u0027value\u0027, \u0027values\u0027 or \u0027fieldValues\u0027 must be provided”}]}

I looked at the network tab when i use the UI to do this and to me the API call looks the same as what I am using.
As you can see I am providing the values parameter? Does anyone know how to call this api successfully?

Thank you very much

Fabian

Hey there.

I was successful with this curl command.

curl -u admin:password -X POST "http://localhost:9000/api/settings/set?component=test&key=sonar.coverage.exclusions&values=**/*"

Have you wrapped the URL in quotes like I did?

Hi Colin

I could not get your curl to work but this one worked but thanks to trying to use curl instead of my original powershell i eventually go it to work. Thank you.

curl -X POST -H "Authorization: Bearer XXXXXXX" -H "Content-Type: application/x-www-form-urlencoded" --data "component=sys.CAMS.CAMSDP.REACT&key=sonar.coverage.exclusions&values=**/*" "https://xxxx/api/settings/set" --verbose

and since i’m using powershell not curl this one worked there

$headers = @{
    "Authorization" = "Bearer squ_XXXXXX"
    "Content-Type" = "application/x-www-form-urlencoded"
}

$body = "component=sys.CAMS.CAMSDP.REACT&key=sonar.coverage.exclusions&values=**/*"

Invoke-RestMethod -Uri "https://xxxxx.com/api/settings/set" -Method Post -Headers $headers -Body $body -Verbose

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