I finally got to connect to sonar from .net using the following code "sonar use Bearer token Authentication":
string responseBody = string.Empty;
var APIUri = "https://sonarcloud.io/";
var VSTSToken = "SonarToken";
// Obtener Listado de proyectos en Azure
uri = "api/issues/search?componentKeys=myproject&impactSeverities=HIGH";
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", VSTSToken);
using (HttpResponseMessage response = await client.GetAsync(APIUri + uri))
{
response.EnsureSuccessStatusCode();
responseBody = await response.Content.ReadAsStringAsync();
}
}
}
catch (Exception ex)
{
//_Logger.LogError(ex.Message);
//Console.WriteLine(ex.ToString());
}