title: Visual Studio Team Services Rest API - How to get 'TeamContext'?
body: <p>I'm trying to build a widget for Visual studio team services dashboard.</p>
  
  <p>When calling APIs from Visual Studio's rest clients, many API requires an 'TeamContext' as input. For example:</p>
  
  <pre><code>IPromise&lt;void&gt; deleteTeamIteration(teamContext, id)
  </code></pre>
  
  <p>But how do I get 'TeamContext'? I tried:</p>
  
  <pre><code>var teamContext = VSS.getWebContext().team; 
  </code></pre>
  
  <p>but it turns out there are two types of TeamContexts (detailed below). <code>VSS.getWebContext.team</code> gives the first kind. While the APIs expect the second kind.</p>
  
  <p>How do I get the second kind of teamContext?</p>
  
  <p><strong>First Kind of TeamContext:</strong></p>
  
  <p><a href="https://www.visualstudio.com/docs/integrate/extensions/reference/client/api/vss/references/sdk_interfaces/teamcontext" rel="nofollow noreferrer">https://www.visualstudio.com/docs/integrate/extensions/reference/client/api/vss/references/sdk_interfaces/teamcontext</a></p>
  
  <p><a href="https://i.stack.imgur.com/drnDu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/drnDu.png" alt="enter image description here"></a></p>
  
  <p><strong>Second Kind of TeamContext:</strong></p>
  
  <p><a href="https://www.visualstudio.com/en-gb/docs/integrate/extensions/reference/client/api/tfs/core/contracts/teamcontext" rel="nofollow noreferrer">https://www.visualstudio.com/en-gb/docs/integrate/extensions/reference/client/api/tfs/core/contracts/teamcontext</a></p>
  
  <p><a href="https://i.stack.imgur.com/IDXF2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IDXF2.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT: 
  A work around is to construct the second type of TeamContext myself.</strong></p>
  
  <pre><code>var teamContext2 = {
      project : VSS.getWebContext().project.name,
      projectId : VSS.getWebContext().project.id,
      team : VSS.getWebContext().team.name,
      teamId : VSS.getWebContext().team.id
  };
  </code></pre>
  
  <p>It's not the most elegant thing, but it works.</p>