403 Insufficient privileges calling api/project_analyses/search

I’m trying to work with your API and retrieve details via the api/project_analyses/search route. I have generated a token and when using it the response is a 403 Forbidden.

http://sonarcloud.io/api/project_analyses/search?name={my token}&project=project-name-123

(We are using Azure AD for authentication). Here’s the response:

Here’s the JSON returned:

    {
        "errors": [
            {
                "msg": "Insufficient privileges"
            }
        ]
    }

To try and get this working I’ve applied all access explicitly at project level for myself. The documentation at (https://sonarcloud.io/web_api/api/project_analyses/search) which states: ‘Requires the following permission: ‘Browse’ on the specified project’. I thought my giving all access I could get this to work - sadly not.

Can anyone provide assistance?

Hi,

In order to query a web service that requires authentication, you need to use your token using HTTP Basic Authentication. More information can be found here: https://docs.sonarqube.org/display/DEV/Web+API.

It’s not possible to set the token in a name parameter of the URL.

Regards

Hi,

Brilliant, your suggestion worked. Many thanks.