I am trying to get all the sonar report issues from a branch of a private Sonarcloud project. I do this with the following REST call:
https://<loginHash>@sonarcloud.io/api/issues/search?projects=<projectKey>&branch=<branchName>
If I enter this call normally in the webbrowser or with a postman call, I get this response:
{
"total": 1,
"p": 1,
"ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
"total": 1
},
"effortTotal": 5,
"debtTotal": 5,
"issues": [
{
...
}
],
...
}
So I get the full report with the 1 sonar issue, like it's shown in the Sonarcloud page.
Now, when I want to do this in Java, the report suddenly has no issues. I do the REST call with a CloseableHttpClient
:
CloseableHttpClient client = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("https://<loginHash>@sonarcloud.io/api/issues/search?projects=<projectKey>&branch=<branchName>");
CloseableHttpResponse response = client.execute(httpGet);
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
System.out.println(body);
And the printed body is this:
{
"total":0,
"p":1,
"ps":100,
"paging":{
"pageIndex":1,
"pageSize":100,
"total":0
},
"effortTotal":0,
"debtTotal":0,
"issues":[],
"components":[],
"organizations":[],
"facets":[]
}
As you can see the issues are now empty. The report does also already exist, so it can't be an issue with that the sonar report isn't ready yet. Any help?