I am trying to read a query through the Team Foundation Server 2015 Rest API. The following code works in Internet Explorer:
var tasksURI = tfs_url + collection + '/' + project + '/_apis/wit/wiql/' + queryId;
$.ajax({
url: tasksURI,
type: 'GET',
contentType: "application/json",
accepts: "application/json",
cache: false,
dataType: 'json'
}).done(function (data) {
var items = [];
$.each(data.workItems, function (key, val) {
items.push("<li> <a href='" + val.url + "'>" + val.id + "</a></li>");
});
$("<ul/>", {
html: items.join("")
}).appendTo("body");
});
In Chrome it yields the following error message:
Failed to load resource: the server responded with a status of 401 (Unauthorized)
I have seen this other question: TFS 2015 REST API Authentication
But I still get the same error if I follow the answer. Also I would prefer to prompt the user for the credentials (like in IE), and not store it.
What am I doing wrong?