Search code examples
azure-devopsazure-devops-rest-apiazure-boards

Any Azure DevOps API to get the value of Microsoft.VSTS.Scheduling.OriginalEstimate for any work item


Any Azure DevOps API to get the value of Microsoft.VSTS.Scheduling.OriginalEstimate for any/all work items in a sprint.


Solution

  • Any Azure DevOps API to get the value of Microsoft.VSTS.Scheduling.OriginalEstimate for any/all work items in a sprint.

    Since you're trying to get workItems with Microsoft.VSTS.Scheduling.OriginalEstimate for specific items in specific spring, you have to combine the usage of WorkItems-Get/Get batch/List and Query by WIQL.

    Here're APIs that can return the Microsoft.VSTS.Scheduling.OriginalEstimate with given Ids:

    1.We can use Get Work Item to get details about one specific work item, the response would contain the info about OriginalEstimate.

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

    enter image description here

    2.We can use Get Work Items Batch to get list of work items based on ids, and we can customize the response based on request body:

    POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitemsbatch?api-version=6.1-preview.1
    

    Request Body:

    {
      "ids": [
        124,
        125
      ],
      "fields": [
        "System.Id",
        "System.Title",
        "System.WorkItemType",
        "Microsoft.VSTS.Scheduling.OriginalEstimate"
      ]
    }
    

    3.Work Items - List can be used to list all or specific workitems with specified fields:

    GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&fields=System.Id,System.Title,System.WorkItemType,Microsoft.VSTS.Scheduling.OriginalEstimate&api-version=6.1-preview.3
    

    Both Get Work Items Batch and Work Items-List can return the workitems with value of Microsoft.VSTS.Scheduling.OriginalEstimate. The difference is that Get Work Items Batch uses Post and define IDs in request body while Work Items-List uses Get and define the IDs as URI parameters.

    Here's API to get workItem id based on WIQL:

    Query By Wiql can return the work Item Ids for specific sprint:

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

    Request Body:

    {
      "query": "Select [System.Id] From WorkItems Where [System.TeamProject] = @project AND [System.IterationPath]= 'YourIterationPath'"
    }
    

    If your IterationPath is a child

    If your IterationPath has such structure, the YourIterationPath above should be replaced with CommonTests or CommonTests\\Iteration 1 depending on your needs.