使用 Javascript 连接具有(kerberos 身份验证)的 TFS-2015 更新 3
Connecting TFS-2015 update 3 which has (kerberos Authentication) using Javascript
我尝试连接 TFS-2015(kerberos 身份验证)
我正在使用下面的 JS-Code,但它没有用:(
$.ajax({
url:
"https://<server>/<collection>/_apis/wit/workitems/api-version=3.0",
type: 'GET',
crossDomain: true,
dataType: 'json',
xhrFields: {
withCredentials: true
}
}).done(function(data){
console.log('done');
console.log(data);
}).fail(function(jqXHR,textStatus ,errorThrown){
console.log('error'); console.log(errorThrown);
});
谁能帮帮我?
你的代码没有问题,它在我这边与 Internet Explorer 一起工作。如果您发现 chrome 有任何问题,请查看此 link 了解详细信息:jQuery ajax requests with Kerberos Authentication.
<script>
$(document).ready(function () {
var query = { "query": "Select [System.Id] from WorkItems Where [System.TeamProject] = 'TeamProjectName' AND [System.WorkItemType] = 'Bug'" };
$.ajax({
url: "http://tfsserver/collectionname/_apis/wit/wiql?api-version=1.0",
type: 'Post',
contentType: 'application/json',
dataType: "json",
data: JSON.stringify(query),
xhrFields: {
withCredentials: true
}
}).done(function(data){
alert('done');
alert(JSON.stringify(data));
}).fail(function(jqXHR,textStatus ,errorThrown){
alert('error');
alert(errorThrown);
});
});
</script>
$(document).ready(function () {
var d = { "query": "Select [System.Id] from WorkItem
Where [System.TeamProject] = '@MR' AND
[System.WorkItemType] = 'Defect'" };
$.ajax({
type: 'GET',
url: "https://<server>/tfs/<collection>",
cache: false,
async: true,
xhrFields: {
withCredentials: true
},
contentType: 'application/json',
data: JSON.stringify(d),
success: function (data) {
console.log(data);
alert('POSTED SUCCESSFULLY TO THE SERVER');
},
error: function (msg, url, line) {
alert(msg);
alert(url);
alert(line);
}
});
});
@Eddie - MSFT
谢谢你的回答
我用这个代码
它似乎有效,但我不确定,因为它返回 HTML 页面
the response in IE
你知道那是什么吗
我尝试连接 TFS-2015(kerberos 身份验证) 我正在使用下面的 JS-Code,但它没有用:(
$.ajax({
url:
"https://<server>/<collection>/_apis/wit/workitems/api-version=3.0",
type: 'GET',
crossDomain: true,
dataType: 'json',
xhrFields: {
withCredentials: true
}
}).done(function(data){
console.log('done');
console.log(data);
}).fail(function(jqXHR,textStatus ,errorThrown){
console.log('error'); console.log(errorThrown);
});
谁能帮帮我?
你的代码没有问题,它在我这边与 Internet Explorer 一起工作。如果您发现 chrome 有任何问题,请查看此 link 了解详细信息:jQuery ajax requests with Kerberos Authentication.
<script>
$(document).ready(function () {
var query = { "query": "Select [System.Id] from WorkItems Where [System.TeamProject] = 'TeamProjectName' AND [System.WorkItemType] = 'Bug'" };
$.ajax({
url: "http://tfsserver/collectionname/_apis/wit/wiql?api-version=1.0",
type: 'Post',
contentType: 'application/json',
dataType: "json",
data: JSON.stringify(query),
xhrFields: {
withCredentials: true
}
}).done(function(data){
alert('done');
alert(JSON.stringify(data));
}).fail(function(jqXHR,textStatus ,errorThrown){
alert('error');
alert(errorThrown);
});
});
</script>
$(document).ready(function () {
var d = { "query": "Select [System.Id] from WorkItem
Where [System.TeamProject] = '@MR' AND
[System.WorkItemType] = 'Defect'" };
$.ajax({
type: 'GET',
url: "https://<server>/tfs/<collection>",
cache: false,
async: true,
xhrFields: {
withCredentials: true
},
contentType: 'application/json',
data: JSON.stringify(d),
success: function (data) {
console.log(data);
alert('POSTED SUCCESSFULLY TO THE SERVER');
},
error: function (msg, url, line) {
alert(msg);
alert(url);
alert(line);
}
});
});
@Eddie - MSFT 谢谢你的回答 我用这个代码 它似乎有效,但我不确定,因为它返回 HTML 页面 the response in IE 你知道那是什么吗