When implement a TFS extension Widget, our team try to use some VSO API to determine the current version control tool is TFVC or Git. We found there is an API in VersionCtrlRestClient
can return the project information. But the following code always fail with an 401 NOT AUTHORIZED error.
import VersionCtrlRestClient = require("TFS/VersionControl/TfvcRestClient");
versionCtrlClient.getProjectInfo("MyProjectName")
.then(projectInfo => {
var cont = $("#content");
cont.append("<pre>" + "TFVC---" + projectInfo.supportsGit + "</pre>");
cont.append("<pre>" + "GIT ---" + projectInfo.supportsGit + "</pre>");
cont.append("<pre>" + "GIT ---" + projectInfo.defaultSourceControlType + "</pre>");
});
Our extension already register into the following scope, and it is ok to call the API to query code changes from the versionCtrlClient
.
"scopes": [ "vso.profile", "vso.work", "vso.work_write", "vso.code", "vso.code_write", "vso.code_manage" ]
Does anyone know what the problem is and how to make the API call "AUTHORIZED"?
PS. In the API document of getProjectInfo
, it is said
* [Obsolete - Use the Projects API instead] Retrieve the version control information for a given Team Project
But where can we find the new API to replace it???