I'm trying to make a dashboard widget in TFS which retrieves information from my SonarQube 6.1 instance (particularly the code coverage of projects). I'm having trouble accessing the web api. My code to access this data currently looks like this:
$.ajax
({
url: myurlapi,
xhrFields: {
withCredentials: true
},
crossDomain: true,
username: "",
password: "",
dataType: 'xml',
async: false,
success: function (data) {
alert(data);
},
error: function(xhr, status, error) {
alert("readyState: " + xhr.readyState);
alert("responseText: "+ xhr.responseText);
alert("status: " + xhr.status);
alert("text status: " + status);
alert("error: " + error);
}
})
I'm getting the following error when I try to run this: "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
I think it's most likely a CORS error as I faced something similar when trying to access Jenkins. I've read that you can't enable CORS from SonarQube, so what alternatives do I have?
Also, the SonarQube server and TFS server are both locally hosted.