Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve work items from Azure DevOps extension?

I successfully followed Microsoft's tutorial to create an extension.

I'm trying to get all the work-items of certain sprint, but to be honest, I'm lost...

I'm not sure what to look for - I have the VSS object, with which I can require additional services (such as TFS/WorkItemTracking/Services or TFS/WorkItemTracking/RestClient).

I found some examples like this one, but couldn't find an API to retrieve or query work items.

Do I need a JS object for that, or is it accomplished via some REST call?

like image 213
Tar Avatar asked Jan 28 '26 19:01

Tar


2 Answers

You are nearly there.

You need the WIT RestClient (assuming you are using Typescript):

import { WorkItemTrackingHttpClient, getClient } from "TFS/WorkItemTracking/RestClient";

With that you can do

const witClient = ((getClient()) as WorkItemTrackingHttpClient);

and then

const result = await witClient.queryByWiql({ query: query });

The WorkItemTrackingHttpClient is all you need to manipulate work items.

EDIT: You could also have a look at the new SDK and API. But unfortunately its lacking a lot on the documentation side. Although there are some samples.

like image 68
Flex Avatar answered Jan 31 '26 07:01

Flex


To query work items, you can can also check this page for WorkItemTrackingHttpClient2_2 client API.

IPromise<Contracts.WorkItemQueryResult> queryById(id, project, team)

IPromise<Contracts.WorkItemQueryResult> queryByWiql(wiql, project, team)

This is also an example about how to get WorkItemTrackingHttpClient and to call Api on Microsoft docs site.

like image 27
Levi Lu-MSFT Avatar answered Jan 31 '26 08:01

Levi Lu-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!