1
votes

I'm trying to build a widget for Visual studio team services dashboard.

When calling APIs from Visual Studio's rest clients, many API requires an 'TeamContext' as input. For example:

IPromise<void> deleteTeamIteration(teamContext, id)

But how do I get 'TeamContext'? I tried:

var teamContext = VSS.getWebContext().team; 

but it turns out there are two types of TeamContexts (detailed below). VSS.getWebContext.team gives the first kind. While the APIs expect the second kind.

How do I get the second kind of teamContext?

First Kind of TeamContext:

https://www.visualstudio.com/docs/integrate/extensions/reference/client/api/vss/references/sdk_interfaces/teamcontext

enter image description here

Second Kind of TeamContext:

https://www.visualstudio.com/en-gb/docs/integrate/extensions/reference/client/api/tfs/core/contracts/teamcontext

enter image description here

EDIT: A work around is to construct the second type of TeamContext myself.

var teamContext2 = {
    project : VSS.getWebContext().project.name,
    projectId : VSS.getWebContext().project.id,
    team : VSS.getWebContext().team.name,
    teamId : VSS.getWebContext().team.id
};

It's not the most elegant thing, but it works.

1

1 Answers

0
votes

The work around is the right way to get it. Refer to this link from MSDN for details: Developing the widget.

var teamContext: TFS_Core_Contracts.TeamContext = { projectId: webContext.project.id, teamId: webContext.team.id, project: "", team: "" };