1

I have next situation and I am stack.

I am using Microsoft.TeamFoundation classes to get workitems from stored query with c#. I know server name, project name and stored query name. So I can execute stored query and receive all WorkItems.

But than I have to create a direct link to this item. According to the documentation, this link should be like

http:// ServerName:8080/tfs/CollectionName/ProjectName/_workitems/edit/Id

So, before executing query I know ServerName, ProjectName and work item's Id. But I cant find ProjectName anywhere.

So my question is. How, knowing ServerName, ProjectName, WorkItemId and Stored Query name get CollectionName?

Or. How to create link to the work item knowing ItemsId?

P.S. GetArtifactUrl is not the right way.

Thanks for help!

Drag13
  • 5,859
  • 1
  • 18
  • 42
  • Which url do you usually use when browsing to see the workitems when you are normaly working with this team project (hint look at that ur) ? Or are you trying to create something that searches in all Team Project Collections ? – Rolf Huisman Aug 01 '16 at 21:21
  • You're question can be interpreted in at least 3 ways. Are you trying this on a on-prem TFS server or on Visual Studio Team Services ? – Rolf Huisman Aug 01 '16 at 21:26
  • I am using on-prem TFS server – Drag13 Aug 02 '16 at 06:45
  • Rolf Huisman I know my URL and I can extract data from here. But question is not about this. I need to extract data from Project + Stored query – Drag13 Aug 02 '16 at 06:48

1 Answers1

2

Afraid there is no such API to achieve this. However, as a workaround, you can list all collection's name through client API such as below:

        Uri configurationServerUri = new Uri(URL);
      TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(configurationServerUri);
                                    ITeamProjectCollectionService tpcService = configurationServer.GetService<ITeamProjectCollectionService>();

    foreach (TeamProjectCollection tpc in tpcService.GetCollections())
                                {
                                    ListCollection.Add(tpc.Name);
                                }

More ways for your reference:

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62