Integrate sonarQube with Sonar Web API

we are trying to integrate sonarqube with salesforce to build a code quality governance system we are getting the response request failed with status code: 403

this is the script i’m working with, can someone help me with this.

// Set the login credentials
String login = '******';
String password = '******';

// Set the POST request URL to start a session
String loginUrl='http://********:9000/api/authentication/login?login= + login + &password= + password;

// Create the POST request
HttpRequest loginRequest = new HttpRequest();

// Send the POST request to start a session
HttpResponse loginResponse = new Http().send(loginRequest);

// Check if the POST request was successful
if (loginResponse.getStatusCode() == 200) {
// Retrieve the session token from the response headers
String sessionToken = loginResponse.getHeader('Set-Cookie').split(';')[0];

// Set the GET request URL to retrieve issues for the componentKeys '***'
String issuesUrl = 'http://**********:9000/api/issues/search?componentKeys=*****';

`// Create the GET request to retrieve issues`
`HttpRequest issuesRequest = new HttpRequest();`

issuesRequest.setHeader('Cookie', sessionToken);

// Send the GET request to retrieve issues in the same session
HttpResponse issuesResponse = new Http().send(issuesRequest);

`// Check if the GET request was successful`

if (issuesResponse.getStatusCode() == 200) {
// Success! Retrieve the response body
String responseBody = issuesResponse.getBody();
} else {
// Request failed. Display the error message
String errorMessage= 'GET request failed with status code: ' + issuesResponse.getStatusCode();
} else {
// Request failed. Display the error message
String errorMessage = 'POST request failed with status code: ' + loginResponse.getStatusCode();

The User has necessary permissions.
SonarQube is community edition and installed in remote server behind a firewall.

  • Community Edition
  • Version 9.8 (build 63668)


don’t know nothing about Salesforce and which programming languages are supported.
You may use the Sonarqube web api via basic authentication and Sonarqube token.

Note = basic authentication uses <token>: means just the token plus delimiter with a blank password

here’s some example with Groovy