We have different types of work items in Azure DevOps Boards. We need to export list of all fields in work items to excel or any similar format. Is there a way to use the APIs to pull a list of all fields in the system and whatever associated metadata is available? Can someone please help us on this task.
You can use Rest Api to get all fields form process template: https://learn.microsoft.com/en-us/rest/api/azure/devops/processes/fields/list?view=azure-devops-rest-7.1
Powershell example:
$user = ""
$token = "<pat>" #https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$orgUrl = "https://dev.azure.com/<org>"
$procId = "<proc-guid>"
$wiRefName = "<wi type name>"
$restApiGetFields = "$orgUrl/_apis/work/processes/$procId/workItemTypes/$wiRefName/fields?api-version=7.1-preview.2"
function InvokeGetRequest ($GetUrl)
{
return Invoke-RestMethod -Uri $GetUrl -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
}
$fields = InvokeGetRequest $restApiGetFields
foreach ($wifield in $fields.value)
{
Write-Host "Name:" $wifield.name "; RefName" $wifield.referenceName
}
Process guild you can get through rest API: https://dev.azure.com/<you_org_name>/_apis/work/processes?api-version=7.1-preview.2
Work Item Type Name you can get from URL while viewing your process template:
UPDATE:
To get information about each field, you need to use FIELD GET rest API with $expand=all
option.