node.jsazure-devopsaws-lambdaazure-devops-rest-api

Get all work items from a project azure devops REST API


I'm using Azure devops API to create a notification bot with AWS Lambda node.js. At this moment i need to check if each task work item is attached to a parent user story.

The first step will be to get all the task work items on "given" project, for this step i was reading azure devops api documentation and found this: Work Items - List

The API is asking for the id of the workitem that i want to get, but what if i need all the workitems from "given" project?

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

Or is there any other way to get all the workitem ids from a given project?


Solution

  • You can use Work Items - Get Work Items Batch API that doesn't require ids but the maximum work items in the results are 200.

    But, if you need to check Tasks, why you need get all the work items in the project? you can get only the Tasks, with Wiql - Query By Wiql API:

    POST https://dev.azure.com/{organization}/{project}/{team}/_apis/wit/wiql?api-version=5.1
    

    In the body make the query:

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