Azure DevOps REST API via az devops invoke (Verified)
CRITICAL LIMITATIONS - READ FIRST
- •
--in-file requires actual file path - Does NOT accept stdin (
-):bash# WRONG - will fail: echo '{}' | az devops invoke --in-file - # CORRECT: echo '{"searchText": "query"}' > /tmp/request.json az devops invoke --in-file /tmp/request.json - •
Comments API doesn't work via invoke - Use
--discussionon update instead:bash# WRONG - returns 404: az devops invoke --area wit --resource comments --route-parameters workItemId=123 # CORRECT - add comment via update: az boards work-item update --id 123 --discussion "My comment" -o json
- •
Route parameters must match exactly - Missing or extra params cause KeyError
Command Pattern
bash
az devops invoke \
--area {AREA} \
--resource {RESOURCE} \
--route-parameters {key}={value} \
--http-method {GET|POST|PUT|PATCH|DELETE} \
--in-file {file.json} \
--api-version {VERSION} \
-o json
Verified Working Examples
Search Work Items (VERIFIED)
Create search payload:
bash
echo '{"searchText": "pipeline", "$top": 10}' > /tmp/search.json
Execute search:
bash
az devops invoke \ --area search \ --resource workitemsearchresults \ --http-method POST \ --in-file /tmp/search.json \ --api-version 7.0 \ -o json
With JMESPath query for clean output:
bash
az devops invoke \
--area search \
--resource workitemsearchresults \
--http-method POST \
--in-file /tmp/search.json \
--api-version 7.0 \
--query "results[].{id:fields.\"system.id\", title:fields.\"system.title\", state:fields.\"system.state\"}" \
-o table
List Boards (VERIFIED)
bash
az devops invoke \ --area work \ --resource boards \ --route-parameters project=ProjectName team="TeamName" \ --api-version 7.0 \ -o json
Get Board Columns (VERIFIED)
bash
az devops invoke \ --area work \ --resource columns \ --route-parameters project=ProjectName team="TeamName" board=Features \ --api-version 7.0 \ -o json
Get Backlogs (VERIFIED)
bash
az devops invoke \ --area work \ --resource backlogs \ --route-parameters project=ProjectName team="TeamName" \ --api-version 7.0 \ -o json
Get Team Capacity
bash
az devops invoke \
--area work \
--resource capacities \
--route-parameters project=ProjectName team="TeamName" iterationId={GUID} \
--api-version 7.0 \
-o json
Verified Areas and Resources
work (Boards & Backlogs)
| Resource | Route Parameters | Verified |
|---|---|---|
| boards | project, team | YES |
| columns | project, team, board | YES |
| backlogs | project, team | YES |
| capacities | project, team, iterationId | - |
| teamdaysoff | project, team, iterationId | - |
search
| Resource | Method | Verified |
|---|---|---|
| workitemsearchresults | POST | YES |
wit (Work Item Tracking)
| Resource | Note |
|---|---|
| comments | NOT WORKING via invoke - use az boards work-item update --discussion instead |
API Discovery
To see ALL available API areas and resources:
bash
az devops invoke -o json > api-discovery.json
This returns 214 areas with 1,407+ resources.
Tips
- •Use temp files for POST bodies - Create in /tmp/, clean up after
- •Quote team names with spaces -
team="Team Name" - •Check resource names - Some use camelCase, others lowercase
- •Use --query for filtering - JMESPath queries reduce output
- •Try 7.0 first - Fall back to preview versions if needed