Reputation: 55
I am using TFS 2015 with Update 2. I am trying to use TFS rest APIs to create, update and delete contents in TFS instead of using the web interface. We have out of the box API from TFS to create a Team project. But there are no APIs listed in TFS Official to create a new Team inside Team project.
I tried Powertools exe. It too doesn't have a method to create new Team.
Could someone please help me with how to create a new Team inside team project using Rest API.
Upvotes: 0
Views: 479
Reputation: 29966
Rest API can only get the teams in Team Project for now, it does not support create teams. Refer to this link for details: Teams. You can submit a feature request on VSTS User Voice.
The alternative way to achieve this is using .NET client libraries for Visual Studio Team Services (and TFS), following is the code sample:
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Client;
namespace ConsoleApplica
{
class Program
{
static void Main(string[] args)
{
string URL = "https://xxxxxx.visualstudio.com/";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(URL));
TfsTeamService tts = ttpc.GetService<TfsTeamService>();
string teamprojecturi = "teamprojecturi";
string newteamname = "newteam";
string teamdescription = "newteamdescription";
IDictionary<string, object> prop = null;//properties, can be null or empty
tts.CreateTeam(teamprojecturi, newteamname,teamdescription,prop);
}
}
}
Upvotes: 2