I am trying to create a task / work item in Visual Studio Team Services (previously Visual Studio Online). My code fails because "tfsStore" returns null value causing the exception to be thrown.
NetworkCredential myNetCredentials = new NetworkCredential("*****", "******");
ICredentials myCredentials = (ICredentials)myNetCredentials;
Uri tfsUri = new Uri("https://*****.visualstudio.com/DefaultCollection/");
var tfsServer = new TfsTeamProjectCollection(tfsUri, myCredentials);
tfsServer.EnsureAuthenticated();
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(tfsUri);
WorkItemStore tfsStore = tfsServer.GetService<WorkItemStore>();
if (tfsStore == null)
{
throw new Exception("Cannot initialize TFS Store");
}
Project teamProject = tfsStore.Projects["******"];
I would appreciate any useful tips as to how to resolve the error. Thanks!