-1

I'm having some troubles to get all workitems/tasks and who is an assignee.

According to this answer is possible get the tasks using the report work, but is retrieving absolutely all.

https://xxx.visualstudio.com/{project}/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&api-version=5.0-preview.2

Is possible retrieve the id, title and who is an assignee?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
wbail
  • 536
  • 1
  • 7
  • 18

2 Answers2

0

You can use below PowerShell script to call the REST API and retrieve the work item id, title and assignee and any other elements you needed.

Alternatively you can export the work item list to a *.csv file.


Param(
   [string]$collectionurl = "https://xxx.visualstudio.com",
   [string]$project = "ProjectName",
   [string]$user = "username",
   [string]$token = "Password/PAT"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$baseUrl = "$collectionurl/$project/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&api-version=5.0-preview.2"         
$response = (Invoke-RestMethod -Uri $baseUrl -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}).values
$wits = $response | where({$_.fields.'System.WorkItemType' -eq 'Task'}) # Only retrieve Tasks

$witrevisions = @()

foreach($wit in $wits){

    $customObject = new-object PSObject -property @{
          "WitID" = $wit.fields.'System.Id'   
          "rev" = $wit.fields.'System.Rev'
          "Title" = $wit.fields.'System.Title'
          "AssignedTo" = $wit.fields.'System.AssignedTo'
          "ChangedDate" = $wit.fields.'System.ChangedDate'
          "ChangedBy" = $wit.fields.'System.ChangedBy'
          "WorkItemType" = $wit.fields.'System.WorkItemType'
        } 

    $witrevisions += $customObject      
}

$witrevisions | Select-Object `
                WitID,
                rev,
                Title, 
                AssignedTo,
                ChangedDate, 
                ChangedBy,
                WorkItemType #| export-csv -Path D:\temp\WIT.csv -NoTypeInformation

enter image description here

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
0

You could add parameter fields=System.Id,System.Title,System.AssignedTo in the api:

GET https://{accountName}.visualstudio.com/{project}/_apis/wit/reporting/workitemrevisions?fields=System.Id,System.Title,System.AssignedTo&includeLatestOnly=true&api-version=5.0-preview.2
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39