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();
loginRequest.setEndpoint(loginUrl);
loginRequest.setMethod('POST');
// 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.setEndpoint(issuesUrl);
issuesRequest.setMethod('GET');
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();
System.debug(responseBody);
} else {
// Request failed. Display the error message
String errorMessage= 'GET request failed with status code: ' + issuesResponse.getStatusCode();
System.debug(errorMessage);
}
} else {
// Request failed. Display the error message
String errorMessage = 'POST request failed with status code: ' + loginResponse.getStatusCode();
System.debug(errorMessage);
}
The User has necessary permissions.
SonarQube is community edition and installed in remote server behind a firewall.
- Community Edition
- Version 9.8 (build 63668)