I'm using the Team Foundation Server API to try to connect to a remote server.
From within my application, I try to connect to a URL of the form https://some-tfs-location.example.com/tfs but when doing so I get an error TF50309 (discussed here). If I add the project collection to the end of the URL (so the path becomes tfs/101
) then I can connect with no problems.
I'd like to try and mimic the behaviour of Visual Studio, where I can give it a URL without needing to specify the project collection and it'll connect and locate the project collection.
Does anyone have any suggestions which API's I can use to mimic the Visual Studio behaviour? I had hoped to find the project collection via
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(projectRoot.ServerUrl,new MyCredentials());
var projectCollection = ttpc.CatalogNode.FullPath;
But this results in the same TF50309 error code.
You can use the TfsConfigurationServer class with the server Uri that has no team project collection (e.g. http://localhost:8080/tfs), get the ITeamProjectCollectionService service, and use GetCollections method or GetDefaultCollection method to retrieve the collection you want.
This blog post described it in more details.