How to get all work items(Epics, Features, Issue, Task, Test Case, User Story, etc) for an Azure Devops project?

azure devops view all work items
azure devops user story template
azure devops work item types
azure devops epic vs feature vs user story
azure devops show tasks on board
azure devops add task to user story
azure devops move work items to backlog
azure devops assign work item to multiple users

I am trying to fetch all the work items(Epics, Features, Issue, Task, Test Case, User Story, etc) and then classify them for a given project using Microsoft's azure devops python api(aka vsts) library.

In the work_item_tracking I am unable to find any function to get all work item or fetch all work item on the basis of it's type.

Is there already a function for getting all work items that I am unable to find or should I write a WIQL query to fetch the required data?

First of all, I am not using the python library, but I can tell you which APIs you have to use.

There is an API to retrieve all the work items. This is just an JSON object with all the work item types and properties. Be aware that this is limited to only 200 workitems each request. If you want more workitems, you have to write a WIQL query.

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&api-version=5.0-preview.3

Personally I would like to advise you to use WIQL Queries to retrieve data from Azure DevOps. It is very flexible and it could be used in any situation.

Here you can find more information about WIQL queries

Here you can find the detailed information about the Azure DevOps Rest API for WIQL Queries

How to get all work items(Epics, Features, Issue, Task, Test Case , I am trying to fetch all the work items(Epics, Features, Issue, Task, Test Case, User Story, etc) This is just an JSON object with all the work item types and GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ advise you to use WIQL Queries to retrieve data from Azure DevOps. User Stories and Tasks are used to track work, Bugs track code defects, and Epics and Features are used to group work under larger scenarios. Each team can configure how they manage Bugs—at the same level as User Stories or Tasks—by configuring the Working with bugs setting.

I'm using this documentation to do this.

With Wiql we can do queries to Azure Devops or TFS, I use Postman to work with it. The first step is use de following url: https://dev.azure.com/{organization}/{projectId}/_apis/wit/wiql?api-version=5.0

Okey the following step is create a query by wiql, to this we will need to use json to send the query:

{
  "query": "Select [System.Id], [System.Title], [System.State], [System.WorkItemType] From WorkItems"
}

If the request it'a 200 Ok you will obtain a json with all Works Items.

My result: Result of my query

Azure devops link work item to wiki, Issue, Task, Test Case, User Story, etc) for an Azure Devops project? Is there already a function for getting all work items that I am unable  Product Backlog Items and Tasks are used to track work, Bugs track code defects, and Epics and Features are used to group work under larger scenarios. Each team can configure how they manage bugs—at the same level as Product Backlog Items or Tasks—by configuring the Working with bugs setting.

Is there already a function for getting all work items that I am unable to find or should I write a WIQL query to fetch the required data?

You are right. We could use write a WIQL query to fetch the System Ids, then we could according system.Ids to query the workitems. The following is the demo code to fetch all of the workitems with python code.

from vsts.vss_connection import VssConnection
from msrest.authentication import BasicAuthentication
import json
from vsts.work_item_tracking.v4_1.models.wiql import Wiql

def emit(msg, *args):
print(msg % args)

def print_work_item(work_item):
    emit(
        "{0} {1}: {2}".format(
            work_item.fields["System.WorkItemType"],
            work_item.id,
            work_item.fields["System.Title"],
        )
    )

personal_access_token = 'YourPATToken'
organization_url = 'https://dev.azure.com/YourorgName'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = VssConnection(base_url=organization_url, creds=credentials)
wiql = Wiql(
        query="""select [System.Id] From WorkItems """
    )

wit_client = connection.get_client('vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient')
wiql_results = wit_client.query_by_wiql(wiql).work_items
if wiql_results:
        # WIQL query gives a WorkItemReference with ID only
        # => we get the corresponding WorkItem from id
        work_items = (
            wit_client.get_work_item(int(res.id)) for res in wiql_results
        )
        for work_item in work_items:
            print_work_item(work_item)

For more demo code, you could refer to this link.

Azure Devops Create Work Item Api, The examples of methods to get work items: Get one work item: Create a task Retrieves the list of all Work Item types in a required Azure DevOps project. Work link types: links work items including select test case Wiki. There's a well known relationship between epics, features, user stories and tasks/bugs in the Agile  Epics, Features, Product Item Backlogs, User Stories, all of those options are available depending on your process template . For the beginners in the Agile world, all of those work items may sound a little bit confusing, even though the Azure DevOps has an specific description for all of them.

Vsts work item types, View Team Project Release Definitions; Clone Azure DevOps Work Items through Azure Usage API – A REST API that customers and partners can use to get their epics, features, issues, tasks, test cases and user stories for later inclusion on Azure Boards Flexible Agile planning for teams of all sizes; Azure Pipelines  The Agile process provides several work item types—for example, user stories, tasks, bugs, features, and epics among others—to plan and track work. We recommend you start by adding user stories. If you need to group them into a hierarchy, you can define features. If you want to track additional details of work, you can add tasks to a user

Azure Devops User Story Template, Im able to migrate work items from tfs to Azure devops except in one case using Vsts Sync migrator. Now open Visual Studio and connect to your target team Project. Click on Epics, Features or User Stories to see the product-level backlog, or one of It is easy to add a new CI build that runs unit tests, VSTS has several  From the web portal for your project, open Boards>Queries and choose the Import Work Items option. Select your CSV file and then choose Import. The import process loads the imported work items into the queries view in an unsaved state. Verify the results are what you want.

Azure Devops Project Configuration - Overview and Boards, We have epics, features, user stories then tasks and hours (which live at task level). If you are familiar with "Agile" or "Scrum" templates in Azure DevOps, an Issue is In some Azure DevOps projects, the same tasks are found repeated in certain types of work item, such as User Stories (Documentation, Unit tests, etc. Or, you can link a user story to a test case from the (links tab). The test case contains a number of fields, many of which are automated and integrated with Test Manager and the build process. For a description of each field, see Query based on build and test integration fields.

Comments
  • No completely clear on how you are using the returned results, but if you are using a query to pull the results and just care about seeing the data, it might be easier to use the Excel Integration to get the work items.
  • Does this api need work item ids since the url specifies - workitems?ids={ids}?
  • How do we get the ids?
  • Thank you, saved me a lot of time. I also used with Postman. I spent some time first to understand that is a POST and not a GET :)