Guest User

Untitled

a guest
Jul 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. GET https://{account}.visualstudio.com/{project}/_apis/wit/workitems/{id}?$expand=Relations&api-version=5.0-preview.3
  2.  
  3. using System;
  4. using Microsoft.VisualStudio.Services.Client;
  5. using Microsoft.VisualStudio.Services.WebApi;
  6. using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
  7. using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
  8.  
  9. namespace GetWorkItemFullyExpanded
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. GetWorkItemFullyExpanded();
  16. }
  17.  
  18. public static WorkItem GetWorkItemFullyExpanded()
  19. {
  20. int id = xx;
  21.  
  22. var myCredentials = new VssClientCredentials();
  23. var connection = new VssConnection(new Uri(@"https://xxxx.visualstudio.com"), myCredentials);
  24. WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient<WorkItemTrackingHttpClient>();
  25.  
  26. WorkItem workitem = workItemTrackingClient.GetWorkItemAsync(id, expand: WorkItemExpand.Relations).Result;
  27.  
  28. Console.WriteLine(workitem.Id);
  29.  
  30. Console.WriteLine("Relations: ");
  31. foreach (var relation in workitem.Relations)
  32. {
  33.  
  34. if (relation.Rel == "Microsoft.VSTS.Common.TestedBy-Forward")
  35. Console.WriteLine(relation.Url);
  36.  
  37. }
  38.  
  39. return workitem;
  40. }
  41.  
  42. }
  43. }
Add Comment
Please, Sign In to add comment