0

Most REST APIs of TFS/VSTS have a JavaScript client for extensions to use. Is there one for /_apis/distributedtask/taskgroups?

I've poked around the files under https://github.com/Microsoft/vss-web-extension-sdk/tree/master/typings , couldn't find one.

We're on TFS 2017u2.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • Are you looking for this https://www.visualstudio.com/en-us/docs/integrate/extensions/reference/client/api/tfs/distributedtask/contracts/taskgroupdefinition? – Cece Dong - MSFT Feb 15 '18 at 04:08
  • I'm looking for something like this: https://www.visualstudio.com/en-us/docs/integrate/extensions/reference/client/api/tfs/core/restclient/corehttpclient2_1 Those JavaScript API wrapper classes exist for a large subset of the TFS REST API surface, they're mostly undocumented (but see the linked Github pages), but they're by far more convenient than direct AJAX. – Seva Alekseyev Feb 15 '18 at 13:35

1 Answers1

0

Yes but it is still in preview. You can search keyword "taskgroup" in tfs.d.ts to get the detailed information.

To use it in your extension:

VSS.require(["VSS/Service", "TFS/DistributedTask/TaskAgentRestClient"], function (VSS_Service, TFS_TA_WebApi) {
var taClient = VSS_Service.getCollectionClient(TFS_TA_WebApi.TaskAgentHttpClient);
taClient.getTaskGroups("ProjectName").then(
    //...
);
});

Remember to add vso.taskgroups scope in your extension. I'm not very sure about TFS2017 Update2, but I tested it on TFS2017 Update3, it works.

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • `VSS_Service.getCollectionClient()` errors out. You can get a REST client object via `TFS_TA_WebApi.getClient()`, but that object doesn't have a `getTaskGroups` method. I'll revisit once we upgrade our TFS. – Seva Alekseyev Feb 22 '18 at 17:45
  • For getCollectionClient? This: Uncaught TypeError: n is not a constructor at n.getHttpClient (Service.js:3) at Object.k [as getCollectionClient] (Service.js:3) at eval (eval at (main.html:319), :1:5) – Seva Alekseyev Feb 23 '18 at 15:53