Search code examples
javascripttfs-2015

Connecting TFS-2015 update 3 which has (kerberos Authentication) using Javascript


I try to connect TFS-2015 (kerberos Authentication) I am using below JS-Code , but it didnt work :(

$.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);
});

Any one can help mehelp me?


Solution

  • There is no issue with your code, it works at my side with Internet Explorer. If you see any issue with chrome, check this link for details: 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>