Reputation: 647
I want to use the TFS API to get a workitem, but it only seems to support getting a workitem by providing an ID field.
I'm making a web portal in which a general account has to find a work item by for example the assigned/area field/project name.
I can't find any documentation on the official page, is this even possible?
Upvotes: 0
Views: 967
Reputation: 89
Here is an example:
Wiql wiql = new Wiql()
{
Query = "Select [State], [Title] " +
"From WorkItems " +
"Where [Work Item Type] = 'Bug' " +
"And [System.TeamProject] = '" + project + "' " +
"And [System.State] <> 'Closed' " +
"Order By [State] Asc, [Changed Date] Desc"
};
//create instance of work item tracking http client
using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(uri, credentials))
{
//execute the query to get the list of work items in the results
WorkItemQueryResult workItemQueryResult = workItemTrackingHttpClient.QueryByWiqlAsync(wiql).Result;
}
Upvotes: 0
Reputation: 4129
If you are using VSTS or some of the newer versions of TFS, you can use the WIQL REST API https://www.visualstudio.com/en-us/docs/integrate/api/wit/wiql There are also code samples on how to use it here https://github.com/Microsoft/vsts-restapi-samplecode/commit/a27a0c48b81f1ba74ea638e8bae46072f645e8af
Upvotes: 1
Reputation: 3165
Getting an work item only by a field (other than Id) will not you guarantee the uniqueness of that work item. It's possible to have more work items with that value.
Upvotes: 0