I've done a new database with a user interface (with Javascript code) and Iam trying to connect the UI with TFS API to get some informations and save it in my Databas but i have challenge in establishing this connectioin with Javascript can anyone help me please??
Asked
Active
Viewed 3,044 times
2
-
Could you describe what you did to solve the problem on your own? – Paul Kertscher Jan 16 '17 at 11:19
-
Which TFS version, most REST API's are not supported in versions older than TFS 2015? Are you using the vso-node-api? https://www.npmjs.com/package/vso-node-api – jessehouwing Jan 16 '17 at 12:07
-
it is TFS 2015 i would make this connection without vso if possible – yahya.müll Jan 16 '17 at 12:48
-
Possible duplicate with this question: http://stackoverflow.com/questions/36072327/tfs-2015-rest-api-authentication – PatrickLu-MSFT Jan 17 '17 at 10:03
1 Answers
0
If you want to do this via a javascript client, you could use the invoke as follows:
var self = this;
self.tasksURI = 'https://<SERVER>/tfs/<COLLECTION>/<PROJECT>/_apis/build/builds?api-version=2.0';
self.username = "<USERNAME>"; //basic username so no domain here.
self.password = "<PASSWORD>";
self.ajax = function (uri, method, data) {
var request = {
url: uri,
type: method,
contentType: "application/json",
accepts: "application/json",
cache: false,
dataType: 'json',
data: JSON.stringify(data),
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(self.username + ":" + self.password));
},
error: function (jqXHR) {
console.log("ajax error " + jqXHR.status);
}
};
return $.ajax(request);
}
self.ajax(self.tasksURI, 'GET').done(function (data) {
alert(data);
});
More details please refer this similar question in SO: TFS 2015 REST API Authentication

Community
- 1
- 1

PatrickLu-MSFT
- 49,478
- 5
- 35
- 62
-
if they use Windows-Authentication how can make the connection, i thought to use (PERSONAL ACCESS TOKEN) but in TFS-2015 there is no (PERSONAL ACCESS TOKEN). what do u think ?? thank u anyway – yahya.müll May 10 '17 at 08:13