0

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???

Esther Fan - MSFT
  • 8,276
  • 4
  • 27
  • 25
Max
  • 175
  • 1
  • 12

1 Answers1

0

The documentation about Project API is here: CoreHttpClient2_2.

To get the version control information, you could use getProject() method with includeCapabilities option. It will returns IPromise that include the version control information.

capabilities: {[key: string]: {[key: string]: string}}. Set of capabilities this project has (such as process template & version control).

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60