Getting a Work Item by ID programmatically using the REST API
In this recipe, you'll learn how to get details of a Work Item programmatically using the WorkItemTrackingHttpClient
REST API.
Getting ready
Refer to instructions in the Getting ready section of the Getting build details programmatically using the REST API recipe for setup details. Download the RESTDemo
solution provided with the course material. In this recipe, we'll be going through the GetWorkItemById
project to get the details of a Work Item.
How to do it…
In the
RESTDemo
solution, setGetWorkItemById
as the startup project:Run the
GetWorkItemById
project, this will launch a console, enter the TFS server URL, and press Enter:Enter the username and password of the user you want to connect to TFS with and press Enter:
Enter the Work Item ID you would like to query the API for:
The console outputs the details of the Work Item such as the Team Project it belongs to, its type, title, state, and created by:
How it works…
We'll go through...