Search code examples
powershellcurlsonarqube

getting "project not found" when trying to do SonarQube curl GET request


I've just started using the SonarQube Web API in my SonarQube instance. I generated a user token per the api documentation.

To test out using the API I tried doing a simple GET request using curl in Powershell like this: curl -u [user token] http://[SonarQube instance IP address]/api/project_branches/list?project=UserAdmin

All I get is this response: {"errors":[{"msg":"Project \u0027UserAdmin\u0027 not found"}]}

I've tried doing the curl request and passing the project parameter like this -d 'project=UserAdmin' and I get the same error response.

I'm not sure what I'm doing wrong.


Solution

  • I solved the issue. When the API endpoint calls for the project name it's the project key not the display name.

    To get the project key, go to your SonarQube instance -> Administration -> Projects. The key will be listed next to the project name.