azure-devops
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAzure DevOps API Skill
Azure DevOps API 指南
This skill provides comprehensive guidance for working with the Azure DevOps REST API, enabling programmatic access to all Azure DevOps Services and Azure DevOps Server resources.
本指南提供了使用Azure DevOps REST API的全面指导,支持以编程方式访问所有Azure DevOps Services和Azure DevOps Server资源。
Overview
概述
Azure DevOps REST API is a RESTful web API enabling you to access and manage work items, repositories, pipelines, test plans, artifacts, and more across all Azure DevOps services.
Base URL:
https://dev.azure.com/{organization}/{project}/_apis/{area}/{resource}?api-version={version}- Organization: Your Azure DevOps organization name
- Project: Project name (optional for org-level resources)
- API Version: Required on all requests (e.g., ,
7.1,7.0)6.0 - Authentication: Personal Access Tokens (PAT), OAuth 2.0, or Azure AD
Azure DevOps REST API是一种RESTful Web API,可让您访问和管理所有Azure DevOps服务中的工作项、代码仓库、流水线、测试计划、制品等资源。
基础URL:
https://dev.azure.com/{organization}/{project}/_apis/{area}/{resource}?api-version={version}- Organization: Azure DevOps组织名称
- Project: 项目名称(组织级资源可选)
- API Version: 所有请求必填(例如:,
7.1,7.0)6.0 - Authentication: 个人访问令牌(PAT)、OAuth 2.0或Azure AD
Quick Start
快速入门
Authentication Requirements
认证要求
Azure DevOps supports multiple authentication methods:
- Personal Access Token (PAT) - Most common for scripts and integrations
- OAuth 2.0 - For web applications
- Azure Active Directory - For enterprise applications
- SSH Keys - For Git operations only
Azure DevOps支持多种认证方式:
- 个人访问令牌(PAT) - 脚本和集成场景最常用
- OAuth 2.0 - 适用于Web应用
- Azure Active Directory - 适用于企业应用
- SSH密钥 - 仅适用于Git操作
Basic PAT Authentication
基础PAT认证
http
GET https://dev.azure.com/{organization}/_apis/projects?api-version=7.1
Authorization: Basic {base64-encoded-PAT}To encode PAT: - Note the colon before the PAT.
base64(":{PAT}")http
GET https://dev.azure.com/{organization}/_apis/projects?api-version=7.1
Authorization: Basic {base64-encoded-PAT}PAT编码方式: - 注意PAT前的冒号。
base64(":{PAT}")Common Request Pattern
通用请求格式
http
GET https://dev.azure.com/{organization}/{project}/_apis/{resource}?api-version=7.1
Authorization: Basic {encoded-PAT}
Content-Type: application/jsonhttp
GET https://dev.azure.com/{organization}/{project}/_apis/{resource}?api-version=7.1
Authorization: Basic {encoded-PAT}
Content-Type: application/jsonCore Services
核心服务
Azure DevOps is organized into major service areas. Each area has its own set of REST APIs:
Azure DevOps分为多个主要服务领域,每个领域都有独立的REST API集合:
Azure Boards - Work Item Tracking
Azure Boards - 工作项跟踪
Work Items
- Create work item:
POST /{organization}/{project}/_apis/wit/workitems/${type}?api-version=7.1 - Get work item:
GET /{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1 - Update work item:
PATCH /{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1 - Delete work item:
DELETE /{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1
Request body uses JSON Patch format:
json
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "New bug report"
},
{
"op": "add",
"path": "/fields/System.AssignedTo",
"value": "user@example.com"
}
]Queries
- Run stored query:
GET /{organization}/{project}/_apis/wit/wiql/{id}?api-version=7.1 - Run WIQL query:
POST /{organization}/{project}/_apis/wit/wiql?api-version=7.1json{ "query": "SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.WorkItemType] = 'Bug' AND [System.State] = 'Active'" }
Boards & Backlogs
- Get boards:
GET /{organization}/{project}/{team}/_apis/work/boards?api-version=7.1 - Get backlog items:
GET /{organization}/{project}/{team}/_apis/work/backlogs/{backlogId}/workItems?api-version=7.1 - Get iterations:
GET /{organization}/{project}/{team}/_apis/work/teamsettings/iterations?api-version=7.1 - Get capacity:
GET /{organization}/{project}/{team}/_apis/work/teamsettings/iterations/{iterationId}/capacities?api-version=7.1
Work Item Types & Fields
- List work item types:
GET /{organization}/{project}/_apis/wit/workitemtypes?api-version=7.1 - List fields:
GET /{organization}/{project}/_apis/wit/fields?api-version=7.1 - Get field:
GET /{organization}/{project}/_apis/wit/fields/{fieldNameOrRefName}?api-version=7.1
Area & Iteration Paths
- Get areas:
GET /{organization}/{project}/_apis/wit/classificationnodes/areas?api-version=7.1 - Get iterations:
GET /{organization}/{project}/_apis/wit/classificationnodes/iterations?api-version=7.1 - Create area:
POST /{organization}/{project}/_apis/wit/classificationnodes/areas?api-version=7.1
工作项
- 创建工作项:
POST /{organization}/{project}/_apis/wit/workitems/${type}?api-version=7.1 - 获取工作项:
GET /{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1 - 更新工作项:
PATCH /{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1 - 删除工作项:
DELETE /{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1
请求体使用JSON Patch格式:
json
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "New bug report"
},
{
"op": "add",
"path": "/fields/System.AssignedTo",
"value": "user@example.com"
}
]查询
- 执行存储查询:
GET /{organization}/{project}/_apis/wit/wiql/{id}?api-version=7.1 - 执行WIQL查询:
POST /{organization}/{project}/_apis/wit/wiql?api-version=7.1json{ "query": "SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.WorkItemType] = 'Bug' AND [System.State] = 'Active'" }
看板与待办事项
- 获取看板:
GET /{organization}/{project}/{team}/_apis/work/boards?api-version=7.1 - 获取待办事项:
GET /{organization}/{project}/{team}/_apis/work/backlogs/{backlogId}/workItems?api-version=7.1 - 获取迭代:
GET /{organization}/{project}/{team}/_apis/work/teamsettings/iterations?api-version=7.1 - 获取团队容量:
GET /{organization}/{project}/{team}/_apis/work/teamsettings/iterations/{iterationId}/capacities?api-version=7.1
工作项类型与字段
- 列出工作项类型:
GET /{organization}/{project}/_apis/wit/workitemtypes?api-version=7.1 - 列出字段:
GET /{organization}/{project}/_apis/wit/fields?api-version=7.1 - 获取字段详情:
GET /{organization}/{project}/_apis/wit/fields/{fieldNameOrRefName}?api-version=7.1
区域与迭代路径
- 获取区域路径:
GET /{organization}/{project}/_apis/wit/classificationnodes/areas?api-version=7.1 - 获取迭代路径:
GET /{organization}/{project}/_apis/wit/classificationnodes/iterations?api-version=7.1 - 创建区域路径:
POST /{organization}/{project}/_apis/wit/classificationnodes/areas?api-version=7.1
Azure Repos - Source Control
Azure Repos - 源代码管理
Git Repositories
- List repositories:
GET /{organization}/{project}/_apis/git/repositories?api-version=7.1 - Get repository:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=7.1 - Create repository:
POST /{organization}/{project}/_apis/git/repositories?api-version=7.1 - Delete repository:
DELETE /{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=7.1
Commits
- Get commits:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?api-version=7.1 - Get commit:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=7.1 - Get commit changes:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/changes?api-version=7.1
Branches
- Get branches:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?filter=heads/&api-version=7.1 - Create branch:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=7.1 - Delete branch:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=7.1json[ { "name": "refs/heads/feature-branch", "oldObjectId": "0000000000000000000000000000000000000000", "newObjectId": "{commitId}" } ]
Pull Requests
- Get pull requests:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1 - Get pull request:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=7.1 - Create pull request:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1json{ "sourceRefName": "refs/heads/feature", "targetRefName": "refs/heads/main", "title": "PR Title", "description": "PR Description" } - Update pull request:
PATCH /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=7.1 - Get PR reviewers:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/reviewers?api-version=7.1 - Add PR reviewer:
PUT /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/reviewers/{reviewerId}?api-version=7.1 - Get PR work items:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/workitems?api-version=7.1 - Get PR threads:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/threads?api-version=7.1 - Add PR comment:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/threads?api-version=7.1
Pushes
- Get pushes:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pushes?api-version=7.1 - Get push:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pushes/{pushId}?api-version=7.1
Items (Files & Folders)
- Get item:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=7.1 - Get item content:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&download=true&api-version=7.1 - Get items batch:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/itemsbatch?api-version=7.1
Policies
- Get policy configurations:
GET /{organization}/{project}/_apis/policy/configurations?api-version=7.1 - Create policy:
POST /{organization}/{project}/_apis/policy/configurations?api-version=7.1
Git仓库
- 列出仓库:
GET /{organization}/{project}/_apis/git/repositories?api-version=7.1 - 获取仓库详情:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=7.1 - 创建仓库:
POST /{organization}/{project}/_apis/git/repositories?api-version=7.1 - 删除仓库:
DELETE /{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=7.1
提交记录
- 获取提交列表:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?api-version=7.1 - 获取提交详情:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=7.1 - 获取提交变更:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/changes?api-version=7.1
分支
- 获取分支列表:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?filter=heads/&api-version=7.1 - 创建分支:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=7.1 - 删除分支:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=7.1json[ { "name": "refs/heads/feature-branch", "oldObjectId": "0000000000000000000000000000000000000000", "newObjectId": "{commitId}" } ]
拉取请求
- 获取拉取请求列表:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1 - 获取拉取请求详情:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=7.1 - 创建拉取请求:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1json{ "sourceRefName": "refs/heads/feature", "targetRefName": "refs/heads/main", "title": "PR Title", "description": "PR Description" } - 更新拉取请求:
PATCH /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=7.1 - 获取拉取请求评审者:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/reviewers?api-version=7.1 - 添加拉取请求评审者:
PUT /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/reviewers/{reviewerId}?api-version=7.1 - 获取拉取请求关联工作项:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/workitems?api-version=7.1 - 获取拉取请求讨论线程:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/threads?api-version=7.1 - 添加拉取请求评论:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}/threads?api-version=7.1
推送记录
- 获取推送列表:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pushes?api-version=7.1 - 获取推送详情:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/pushes/{pushId}?api-version=7.1
文件与文件夹
- 获取文件/文件夹信息:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=7.1 - 获取文件内容:
GET /{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&download=true&api-version=7.1 - 批量获取文件信息:
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/itemsbatch?api-version=7.1
仓库策略
- 获取策略配置:
GET /{organization}/{project}/_apis/policy/configurations?api-version=7.1 - 创建策略:
POST /{organization}/{project}/_apis/policy/configurations?api-version=7.1
Azure Pipelines - CI/CD
Azure Pipelines - CI/CD
Build Definitions (Pipelines)
- List definitions:
GET /{organization}/{project}/_apis/build/definitions?api-version=7.1 - Get definition:
GET /{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1 - Create definition:
POST /{organization}/{project}/_apis/build/definitions?api-version=7.1 - Update definition:
PUT /{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1 - Delete definition:
DELETE /{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1
Builds
- Queue build:
POST /{organization}/{project}/_apis/build/builds?api-version=7.1json{ "definition": { "id": 123 }, "sourceBranch": "refs/heads/main" } - Get builds:
GET /{organization}/{project}/_apis/build/builds?api-version=7.1 - Get build:
GET /{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1 - Update build:
PATCH /{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1 - Delete build:
DELETE /{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1 - Get build logs:
GET /{organization}/{project}/_apis/build/builds/{buildId}/logs?api-version=7.1 - Get build timeline:
GET /{organization}/{project}/_apis/build/builds/{buildId}/timeline?api-version=7.1 - Get build artifacts:
GET /{organization}/{project}/_apis/build/builds/{buildId}/artifacts?api-version=7.1
Release Definitions
- List definitions:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=7.1 - Get definition:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=7.1 - Create definition:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=7.1
Releases
- Create release:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1 - Get releases:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1 - Get release:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=7.1 - Update release:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=7.1 - Get release environment:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}?api-version=7.1 - Update release environment:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}?api-version=7.1
Approvals
- Get approvals:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/approvals?api-version=7.1 - Update approval:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/approvals/{approvalId}?api-version=7.1
Agent Pools
- List pools:
GET /{organization}/_apis/distributedtask/pools?api-version=7.1 - Get pool:
GET /{organization}/_apis/distributedtask/pools/{poolId}?api-version=7.1 - Add pool:
POST /{organization}/_apis/distributedtask/pools?api-version=7.1
Agents
- List agents:
GET /{organization}/_apis/distributedtask/pools/{poolId}/agents?api-version=7.1 - Get agent:
GET /{organization}/_apis/distributedtask/pools/{poolId}/agents/{agentId}?api-version=7.1 - Update agent:
PATCH /{organization}/_apis/distributedtask/pools/{poolId}/agents/{agentId}?api-version=7.1
Variable Groups
- List variable groups:
GET /{organization}/{project}/_apis/distributedtask/variablegroups?api-version=7.1 - Get variable group:
GET /{organization}/{project}/_apis/distributedtask/variablegroups/{groupId}?api-version=7.1 - Create variable group:
POST /{organization}/{project}/_apis/distributedtask/variablegroups?api-version=7.1 - Update variable group:
PUT /{organization}/{project}/_apis/distributedtask/variablegroups/{groupId}?api-version=7.1
Task Groups
- List task groups:
GET /{organization}/{project}/_apis/distributedtask/taskgroups?api-version=7.1 - Get task group:
GET /{organization}/{project}/_apis/distributedtask/taskgroups/{taskGroupId}?api-version=7.1
Service Endpoints (Connections)
- List endpoints:
GET /{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=7.1 - Get endpoint:
GET /{organization}/{project}/_apis/serviceendpoint/endpoints/{endpointId}?api-version=7.1 - Create endpoint:
POST /{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=7.1
构建定义(流水线)
- 列出构建定义:
GET /{organization}/{project}/_apis/build/definitions?api-version=7.1 - 获取构建定义详情:
GET /{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1 - 创建构建定义:
POST /{organization}/{project}/_apis/build/definitions?api-version=7.1 - 更新构建定义:
PUT /{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1 - 删除构建定义:
DELETE /{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1
构建任务
- 触发构建:
POST /{organization}/{project}/_apis/build/builds?api-version=7.1json{ "definition": { "id": 123 }, "sourceBranch": "refs/heads/main" } - 获取构建列表:
GET /{organization}/{project}/_apis/build/builds?api-version=7.1 - 获取构建详情:
GET /{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1 - 更新构建:
PATCH /{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1 - 删除构建:
DELETE /{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1 - 获取构建日志:
GET /{organization}/{project}/_apis/build/builds/{buildId}/logs?api-version=7.1 - 获取构建时间线:
GET /{organization}/{project}/_apis/build/builds/{buildId}/timeline?api-version=7.1 - 获取构建制品:
GET /{organization}/{project}/_apis/build/builds/{buildId}/artifacts?api-version=7.1
发布定义
- 列出发布定义:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=7.1 - 获取发布定义详情:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=7.1 - 创建发布定义:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=7.1
发布任务
- 触发发布:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1 - 获取发布列表:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1 - 获取发布详情:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=7.1 - 更新发布:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=7.1 - 获取发布环境详情:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}?api-version=7.1 - 更新发布环境:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}?api-version=7.1
审批
- 获取审批列表:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/approvals?api-version=7.1 - 更新审批状态:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/approvals/{approvalId}?api-version=7.1
代理池
- 列出代理池:
GET /{organization}/_apis/distributedtask/pools?api-version=7.1 - 获取代理池详情:
GET /{organization}/_apis/distributedtask/pools/{poolId}?api-version=7.1 - 添加代理池:
POST /{organization}/_apis/distributedtask/pools?api-version=7.1
代理节点
- 列出代理节点:
GET /{organization}/_apis/distributedtask/pools/{poolId}/agents?api-version=7.1 - 获取代理节点详情:
GET /{organization}/_apis/distributedtask/pools/{poolId}/agents/{agentId}?api-version=7.1 - 更新代理节点:
PATCH /{organization}/_apis/distributedtask/pools/{poolId}/agents/{agentId}?api-version=7.1
变量组
- 列出变量组:
GET /{organization}/{project}/_apis/distributedtask/variablegroups?api-version=7.1 - 获取变量组详情:
GET /{organization}/{project}/_apis/distributedtask/variablegroups/{groupId}?api-version=7.1 - 创建变量组:
POST /{organization}/{project}/_apis/distributedtask/variablegroups?api-version=7.1 - 更新变量组:
PUT /{organization}/{project}/_apis/distributedtask/variablegroups/{groupId}?api-version=7.1
任务组
- 列出任务组:
GET /{organization}/{project}/_apis/distributedtask/taskgroups?api-version=7.1 - 获取任务组详情:
GET /{organization}/{project}/_apis/distributedtask/taskgroups/{taskGroupId}?api-version=7.1
服务连接
- 列出服务连接:
GET /{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=7.1 - 获取服务连接详情:
GET /{organization}/{project}/_apis/serviceendpoint/endpoints/{endpointId}?api-version=7.1 - 创建服务连接:
POST /{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=7.1
Azure Test Plans
Azure Test Plans
Test Plans
- List test plans:
GET /{organization}/{project}/_apis/testplan/plans?api-version=7.1 - Get test plan:
GET /{organization}/{project}/_apis/testplan/plans/{planId}?api-version=7.1 - Create test plan:
POST /{organization}/{project}/_apis/testplan/plans?api-version=7.1 - Update test plan:
PATCH /{organization}/{project}/_apis/testplan/plans/{planId}?api-version=7.1
Test Suites
- List test suites:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites?api-version=7.1 - Get test suite:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}?api-version=7.1 - Create test suite:
POST /{organization}/{project}/_apis/testplan/plans/{planId}/suites?api-version=7.1
Test Cases
- List test cases:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}/testcases?api-version=7.1 - Get test case:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}/testcases/{testCaseId}?api-version=7.1 - Add test cases:
POST /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}/testcases?api-version=7.1
Test Runs
- Create test run:
POST /{organization}/{project}/_apis/test/runs?api-version=7.1 - Get test runs:
GET /{organization}/{project}/_apis/test/runs?api-version=7.1 - Get test run:
GET /{organization}/{project}/_apis/test/runs/{runId}?api-version=7.1 - Update test run:
PATCH /{organization}/{project}/_apis/test/runs/{runId}?api-version=7.1
Test Results
- Get test results:
GET /{organization}/{project}/_apis/test/runs/{runId}/results?api-version=7.1 - Get test result:
GET /{organization}/{project}/_apis/test/runs/{runId}/results/{resultId}?api-version=7.1 - Update test results:
PATCH /{organization}/{project}/_apis/test/runs/{runId}/results?api-version=7.1 - Add test results:
POST /{organization}/{project}/_apis/test/runs/{runId}/results?api-version=7.1
Test Configurations
- List configurations:
GET /{organization}/{project}/_apis/testplan/configurations?api-version=7.1 - Get configuration:
GET /{organization}/{project}/_apis/testplan/configurations/{configurationId}?api-version=7.1
测试计划
- 列出测试计划:
GET /{organization}/{project}/_apis/testplan/plans?api-version=7.1 - 获取测试计划详情:
GET /{organization}/{project}/_apis/testplan/plans/{planId}?api-version=7.1 - 创建测试计划:
POST /{organization}/{project}/_apis/testplan/plans?api-version=7.1 - 更新测试计划:
PATCH /{organization}/{project}/_apis/testplan/plans/{planId}?api-version=7.1
测试套件
- 列出测试套件:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites?api-version=7.1 - 获取测试套件详情:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}?api-version=7.1 - 创建测试套件:
POST /{organization}/{project}/_apis/testplan/plans/{planId}/suites?api-version=7.1
测试用例
- 列出测试用例:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}/testcases?api-version=7.1 - 获取测试用例详情:
GET /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}/testcases/{testCaseId}?api-version=7.1 - 添加测试用例:
POST /{organization}/{project}/_apis/testplan/plans/{planId}/suites/{suiteId}/testcases?api-version=7.1
测试运行
- 创建测试运行:
POST /{organization}/{project}/_apis/test/runs?api-version=7.1 - 获取测试运行列表:
GET /{organization}/{project}/_apis/test/runs?api-version=7.1 - 获取测试运行详情:
GET /{organization}/{project}/_apis/test/runs/{runId}?api-version=7.1 - 更新测试运行:
PATCH /{organization}/{project}/_apis/test/runs/{runId}?api-version=7.1
测试结果
- 获取测试结果列表:
GET /{organization}/{project}/_apis/test/runs/{runId}/results?api-version=7.1 - 获取测试结果详情:
GET /{organization}/{project}/_apis/test/runs/{runId}/results/{resultId}?api-version=7.1 - 更新测试结果:
PATCH /{organization}/{project}/_apis/test/runs/{runId}/results?api-version=7.1 - 添加测试结果:
POST /{organization}/{project}/_apis/test/runs/{runId}/results?api-version=7.1
测试配置
- 列出测试配置:
GET /{organization}/{project}/_apis/testplan/configurations?api-version=7.1 - 获取测试配置详情:
GET /{organization}/{project}/_apis/testplan/configurations/{configurationId}?api-version=7.1
Azure Artifacts
Azure Artifacts
Feeds
- List feeds:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds?api-version=7.1 - Get feed:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}?api-version=7.1 - Create feed:
POST https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds?api-version=7.1 - Update feed:
PATCH https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}?api-version=7.1
Packages
- List packages:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages?api-version=7.1 - Get package:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}?api-version=7.1 - Delete package:
DELETE https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}?api-version=7.1
Package Versions
- List package versions:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}/versions?api-version=7.1 - Get package version:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}/versions/{versionId}?api-version=7.1 - Delete package version:
DELETE https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}/versions/{versionId}?api-version=7.1
Feed Permissions
- Get feed permissions:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/permissions?api-version=7.1 - Set feed permissions:
PATCH https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/permissions?api-version=7.1
制品源
- 列出制品源:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds?api-version=7.1 - 获取制品源详情:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}?api-version=7.1 - 创建制品源:
POST https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds?api-version=7.1 - 更新制品源:
PATCH https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}?api-version=7.1
制品包
- 列出制品包:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages?api-version=7.1 - 获取制品包详情:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}?api-version=7.1 - 删除制品包:
DELETE https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}?api-version=7.1
制品包版本
- 列出制品包版本:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}/versions?api-version=7.1 - 获取制品包版本详情:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}/versions/{versionId}?api-version=7.1 - 删除制品包版本:
DELETE https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/packages/{packageId}/versions/{versionId}?api-version=7.1
制品源权限
- 获取制品源权限:
GET https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/permissions?api-version=7.1 - 设置制品源权限:
PATCH https://feeds.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/permissions?api-version=7.1
Organization & Project Management
组织与项目管理
Organizations
- List organizations: Available via Azure DevOps Profile API
- Get organization details:
GET https://dev.azure.com/{organization}/_apis/projectcollections?api-version=7.1
Projects
- List projects:
GET /{organization}/_apis/projects?api-version=7.1 - Get project:
GET /{organization}/_apis/projects/{projectId}?api-version=7.1 - Create project:
POST /{organization}/_apis/projects?api-version=7.1json{ "name": "MyProject", "description": "Project description", "capabilities": { "versioncontrol": { "sourceControlType": "Git" }, "processTemplate": { "templateTypeId": "6b724908-ef14-45cf-84f8-768b5384da45" } } } - Update project:
PATCH /{organization}/_apis/projects/{projectId}?api-version=7.1 - Delete project:
DELETE /{organization}/_apis/projects/{projectId}?api-version=7.1
Teams
- List teams:
GET /{organization}/_apis/teams?api-version=7.1 - Get team:
GET /{organization}/_apis/projects/{projectId}/teams/{teamId}?api-version=7.1 - Create team:
POST /{organization}/_apis/projects/{projectId}/teams?api-version=7.1 - Update team:
PATCH /{organization}/_apis/projects/{projectId}/teams/{teamId}?api-version=7.1 - Delete team:
DELETE /{organization}/_apis/projects/{projectId}/teams/{teamId}?api-version=7.1
Team Members
- Get team members:
GET /{organization}/_apis/projects/{projectId}/teams/{teamId}/members?api-version=7.1 - Add team member:
PUT /{organization}/_apis/projects/{projectId}/teams/{teamId}/members/{userId}?api-version=7.1 - Remove team member:
DELETE /{organization}/_apis/projects/{projectId}/teams/{teamId}/members/{userId}?api-version=7.1
Processes
- List processes:
GET /{organization}/_apis/process/processes?api-version=7.1 - Get process:
GET /{organization}/_apis/process/processes/{processId}?api-version=7.1 - Create process:
POST /{organization}/_apis/process/processes?api-version=7.1
组织
- 列出组织: 通过Azure DevOps Profile API获取
- 获取组织详情:
GET https://dev.azure.com/{organization}/_apis/projectcollections?api-version=7.1
项目
- 列出项目:
GET /{organization}/_apis/projects?api-version=7.1 - 获取项目详情:
GET /{organization}/_apis/projects/{projectId}?api-version=7.1 - 创建项目:
POST /{organization}/_apis/projects?api-version=7.1json{ "name": "MyProject", "description": "Project description", "capabilities": { "versioncontrol": { "sourceControlType": "Git" }, "processTemplate": { "templateTypeId": "6b724908-ef14-45cf-84f8-768b5384da45" } } } - 更新项目:
PATCH /{organization}/_apis/projects/{projectId}?api-version=7.1 - 删除项目:
DELETE /{organization}/_apis/projects/{projectId}?api-version=7.1
团队
- 列出团队:
GET /{organization}/_apis/teams?api-version=7.1 - 获取团队详情:
GET /{organization}/_apis/projects/{projectId}/teams/{teamId}?api-version=7.1 - 创建团队:
POST /{organization}/_apis/projects/{projectId}/teams?api-version=7.1 - 更新团队:
PATCH /{organization}/_apis/projects/{projectId}/teams/{teamId}?api-version=7.1 - 删除团队:
DELETE /{organization}/_apis/projects/{projectId}/teams/{teamId}?api-version=7.1
团队成员
- 获取团队成员:
GET /{organization}/_apis/projects/{projectId}/teams/{teamId}/members?api-version=7.1 - 添加团队成员:
PUT /{organization}/_apis/projects/{projectId}/teams/{teamId}/members/{userId}?api-version=7.1 - 移除团队成员:
DELETE /{organization}/_apis/projects/{projectId}/teams/{teamId}/members/{userId}?api-version=7.1
流程模板
- 列出流程模板:
GET /{organization}/_apis/process/processes?api-version=7.1 - 获取流程模板详情:
GET /{organization}/_apis/process/processes/{processId}?api-version=7.1 - 创建流程模板:
POST /{organization}/_apis/process/processes?api-version=7.1
Security & Identity
安全与身份管理
Identities (Users & Groups)
- Read identities:
GET https://vssps.dev.azure.com/{organization}/_apis/identities?api-version=7.1 - Read identity:
GET https://vssps.dev.azure.com/{organization}/_apis/identities/{identityId}?api-version=7.1
Graph (Azure DevOps specific)
- List users:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=7.1-preview.1 - Get user:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users/{userDescriptor}?api-version=7.1-preview.1 - Create user:
POST https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=7.1-preview.1 - Delete user:
DELETE https://vssps.dev.azure.com/{organization}/_apis/graph/users/{userDescriptor}?api-version=7.1-preview.1
Groups
- List groups:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=7.1-preview.1 - Get group:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups/{groupDescriptor}?api-version=7.1-preview.1 - Create group:
POST https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=7.1-preview.1 - Delete group:
DELETE https://vssps.dev.azure.com/{organization}/_apis/graph/groups/{groupDescriptor}?api-version=7.1-preview.1
Group Memberships
- List memberships:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}?api-version=7.1-preview.1 - Add membership:
PUT https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}/{containerDescriptor}?api-version=7.1-preview.1 - Remove membership:
DELETE https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}/{containerDescriptor}?api-version=7.1-preview.1
Access Control Lists (ACLs)
- Query ACLs:
GET /{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=7.1 - Set ACLs:
POST /{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=7.1 - Remove ACLs:
DELETE /{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=7.1
Security Namespaces
- List security namespaces:
GET /{organization}/_apis/securitynamespaces?api-version=7.1 - Get security namespace:
GET /{organization}/_apis/securitynamespaces/{securityNamespaceId}?api-version=7.1
Permissions
- Query permissions:
GET /{organization}/_apis/permissions/{securityNamespaceId}/{permissions}?api-version=7.1 - Check permission:
GET /{organization}/_apis/security/permissions/{securityNamespaceId}?api-version=7.1
身份(用户与组)
- 读取身份列表:
GET https://vssps.dev.azure.com/{organization}/_apis/identities?api-version=7.1 - 读取身份详情:
GET https://vssps.dev.azure.com/{organization}/_apis/identities/{identityId}?api-version=7.1
Graph(Azure DevOps专属)
- 列出用户:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=7.1-preview.1 - 获取用户详情:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users/{userDescriptor}?api-version=7.1-preview.1 - 创建用户:
POST https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=7.1-preview.1 - 删除用户:
DELETE https://vssps.dev.azure.com/{organization}/_apis/graph/users/{userDescriptor}?api-version=7.1-preview.1
用户组
- 列出用户组:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=7.1-preview.1 - 获取用户组详情:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups/{groupDescriptor}?api-version=7.1-preview.1 - 创建用户组:
POST https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=7.1-preview.1 - 删除用户组:
DELETE https://vssps.dev.azure.com/{organization}/_apis/graph/groups/{groupDescriptor}?api-version=7.1-preview.1
组成员关系
- 列出组成员关系:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}?api-version=7.1-preview.1 - 添加组成员:
PUT https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}/{containerDescriptor}?api-version=7.1-preview.1 - 移除组成员:
DELETE https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}/{containerDescriptor}?api-version=7.1-preview.1
访问控制列表(ACL)
- 查询ACL:
GET /{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=7.1 - 设置ACL:
POST /{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=7.1 - 移除ACL:
DELETE /{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=7.1
安全命名空间
- 列出安全命名空间:
GET /{organization}/_apis/securitynamespaces?api-version=7.1 - 获取安全命名空间详情:
GET /{organization}/_apis/securitynamespaces/{securityNamespaceId}?api-version=7.1
权限
- 查询权限:
GET /{organization}/_apis/permissions/{securityNamespaceId}/{permissions}?api-version=7.1 - 检查权限:
GET /{organization}/_apis/security/permissions/{securityNamespaceId}?api-version=7.1
Extensions & Integrations
扩展与集成
Extensions
- List installed extensions:
GET /{organization}/_apis/extensionmanagement/installedextensions?api-version=7.1 - Get installed extension:
GET /{organization}/_apis/extensionmanagement/installedextensions/{publisherName}/{extensionName}?api-version=7.1 - Install extension:
POST /{organization}/_apis/extensionmanagement/installedextensions?api-version=7.1 - Uninstall extension:
DELETE /{organization}/_apis/extensionmanagement/installedextensions/{publisherName}/{extensionName}?api-version=7.1
Service Hooks
- List subscriptions:
GET /{organization}/_apis/hooks/subscriptions?api-version=7.1 - Get subscription:
GET /{organization}/_apis/hooks/subscriptions/{subscriptionId}?api-version=7.1 - Create subscription:
POST /{organization}/_apis/hooks/subscriptions?api-version=7.1json{ "publisherId": "tfs", "eventType": "git.push", "resourceVersion": "1.0", "consumerId": "webHooks", "consumerActionId": "httpRequest", "publisherInputs": { "projectId": "{projectId}" }, "consumerInputs": { "url": "https://example.com/webhook" } } - Delete subscription:
DELETE /{organization}/_apis/hooks/subscriptions/{subscriptionId}?api-version=7.1
Notifications
- List subscriptions:
GET /{organization}/_apis/notification/subscriptions?api-version=7.1 - Create subscription:
POST /{organization}/_apis/notification/subscriptions?api-version=7.1
扩展
- 列出已安装扩展:
GET /{organization}/_apis/extensionmanagement/installedextensions?api-version=7.1 - 获取已安装扩展详情:
GET /{organization}/_apis/extensionmanagement/installedextensions/{publisherName}/{extensionName}?api-version=7.1 - 安装扩展:
POST /{organization}/_apis/extensionmanagement/installedextensions?api-version=7.1 - 卸载扩展:
DELETE /{organization}/_apis/extensionmanagement/installedextensions/{publisherName}/{extensionName}?api-version=7.1
服务挂钩
- 列出订阅:
GET /{organization}/_apis/hooks/subscriptions?api-version=7.1 - 获取订阅详情:
GET /{organization}/_apis/hooks/subscriptions/{subscriptionId}?api-version=7.1 - 创建订阅:
POST /{organization}/_apis/hooks/subscriptions?api-version=7.1json{ "publisherId": "tfs", "eventType": "git.push", "resourceVersion": "1.0", "consumerId": "webHooks", "consumerActionId": "httpRequest", "publisherInputs": { "projectId": "{projectId}" }, "consumerInputs": { "url": "https://example.com/webhook" } } - 删除订阅:
DELETE /{organization}/_apis/hooks/subscriptions/{subscriptionId}?api-version=7.1
通知
- 列出通知订阅:
GET /{organization}/_apis/notification/subscriptions?api-version=7.1 - 创建通知订阅:
POST /{organization}/_apis/notification/subscriptions?api-version=7.1
Additional Services
附加服务
Wiki
- List wikis:
GET /{organization}/{project}/_apis/wiki/wikis?api-version=7.1 - Get wiki:
GET /{organization}/{project}/_apis/wiki/wikis/{wikiId}?api-version=7.1 - Create wiki:
POST /{organization}/{project}/_apis/wiki/wikis?api-version=7.1 - Get wiki page:
GET /{organization}/{project}/_apis/wiki/wikis/{wikiId}/pages?path={path}&api-version=7.1 - Create/update wiki page:
PUT /{organization}/{project}/_apis/wiki/wikis/{wikiId}/pages?path={path}&api-version=7.1
Search
- Search work items:
POST /{organization}/{project}/_apis/search/workitemsearchresults?api-version=7.1 - Search code:
POST /{organization}/{project}/_apis/search/codesearchresults?api-version=7.1
Dashboards
- List dashboards:
GET /{organization}/{project}/{team}/_apis/dashboard/dashboards?api-version=7.1 - Get dashboard:
GET /{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}?api-version=7.1 - Create dashboard:
POST /{organization}/{project}/{team}/_apis/dashboard/dashboards?api-version=7.1
Widgets
- List widgets:
GET /{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}/widgets?api-version=7.1 - Create widget:
POST /{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}/widgets?api-version=7.1
Audit
- Query audit log:
GET /{organization}/_apis/audit/auditlog?api-version=7.1-preview.1 - Download audit log:
GET /{organization}/_apis/audit/downloadlog?api-version=7.1-preview.1
Wiki
- 列出Wiki:
GET /{organization}/{project}/_apis/wiki/wikis?api-version=7.1 - 获取Wiki详情:
GET /{organization}/{project}/_apis/wiki/wikis/{wikiId}?api-version=7.1 - 创建Wiki:
POST /{organization}/{project}/_apis/wiki/wikis?api-version=7.1 - 获取Wiki页面:
GET /{organization}/{project}/_apis/wiki/wikis/{wikiId}/pages?path={path}&api-version=7.1 - 创建/更新Wiki页面:
PUT /{organization}/{project}/_apis/wiki/wikis/{wikiId}/pages?path={path}&api-version=7.1
搜索
- 搜索工作项:
POST /{organization}/{project}/_apis/search/workitemsearchresults?api-version=7.1 - 搜索代码:
POST /{organization}/{project}/_apis/search/codesearchresults?api-version=7.1
仪表板
- 列出仪表板:
GET /{organization}/{project}/{team}/_apis/dashboard/dashboards?api-version=7.1 - 获取仪表板详情:
GET /{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}?api-version=7.1 - 创建仪表板:
POST /{organization}/{project}/{team}/_apis/dashboard/dashboards?api-version=7.1
小部件
- 列出小部件:
GET /{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}/widgets?api-version=7.1 - 创建小部件:
POST /{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}/widgets?api-version=7.1
审计日志
- 查询审计日志:
GET /{organization}/_apis/audit/auditlog?api-version=7.1-preview.1 - 下载审计日志:
GET /{organization}/_apis/audit/downloadlog?api-version=7.1-preview.1
Common Operations
通用操作
Pagination
分页
Azure DevOps API uses continuation tokens for pagination:
Response with continuation token:
json
{
"count": 100,
"value": [...],
"continuationToken": "MTIz"
}Next request:
http
GET /{endpoint}?continuationToken=MTIz&api-version=7.1Some endpoints use and :
$top$skiphttp
GET /{endpoint}?$top=100&$skip=100&api-version=7.1Azure DevOps API使用延续令牌实现分页:
包含延续令牌的响应:
json
{
"count": 100,
"value": [...],
"continuationToken": "MTIz"
}下一页请求:
http
GET /{endpoint}?continuationToken=MTIz&api-version=7.1部分端点使用和参数:
$top$skiphttp
GET /{endpoint}?$top=100&$skip=100&api-version=7.1Filtering & Querying
过滤与查询
OData-style filters (select endpoints):
http
GET /{endpoint}?$filter=state eq 'Active'&api-version=7.1Work item queries use WIQL (Work Item Query Language):
sql
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.WorkItemType] = 'Bug'
AND [System.State] = 'Active'
AND [System.AssignedTo] = @Me
ORDER BY [System.ChangedDate] DESCOData风格过滤(部分端点支持):
http
GET /{endpoint}?$filter=state eq 'Active'&api-version=7.1工作项查询使用WIQL(工作项查询语言):
sql
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.WorkItemType] = 'Bug'
AND [System.State] = 'Active'
AND [System.AssignedTo] = @Me
ORDER BY [System.ChangedDate] DESCBatch Operations
批量操作
Some Azure DevOps APIs support batch operations:
Work Items batch get:
http
GET /{organization}/_apis/wit/workitemsbatch?ids=1,2,3,4,5&api-version=7.1Git items batch:
http
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/itemsbatch?api-version=7.1
{
"itemDescriptors": [
{"path": "/file1.txt", "version": "main"},
{"path": "/file2.txt", "version": "main"}
]
}部分Azure DevOps API支持批量操作:
批量获取工作项:
http
GET /{organization}/_apis/wit/workitemsbatch?ids=1,2,3,4,5&api-version=7.1批量获取Git文件:
http
POST /{organization}/{project}/_apis/git/repositories/{repositoryId}/itemsbatch?api-version=7.1
{
"itemDescriptors": [
{"path": "/file1.txt", "version": "main"},
{"path": "/file2.txt", "version": "main"}
]
}JSON Patch for Updates
JSON Patch更新
Work items and some other resources use JSON Patch (RFC 6902):
Operations:
- - Add a field or relationship
add - - Remove a field
remove - - Replace field value
replace - - Test a value (for concurrency)
test - - Copy a value
copy - - Move a value
move
Example:
json
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "New title"
},
{
"op": "replace",
"path": "/fields/System.State",
"value": "Active"
},
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/{org}/_apis/wit/workItems/123"
}
}
]工作项和部分其他资源使用JSON Patch(RFC 6902)格式进行更新:
操作类型:
- - 添加字段或关联关系
add - - 删除字段
remove - - 替换字段值
replace - - 测试值(用于并发控制)
test - - 复制值
copy - - 移动值
move
示例:
json
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "New title"
},
{
"op": "replace",
"path": "/fields/System.State",
"value": "Active"
},
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/{org}/_apis/wit/workItems/123"
}
}
]Error Handling
错误处理
Azure DevOps API returns standard HTTP status codes:
- - Success
200 OK - - Resource created
201 Created - - Request accepted (async operation)
202 Accepted - - Success, no content
204 No Content - - Invalid request
400 Bad Request - - Authentication required
401 Unauthorized - - Insufficient permissions
403 Forbidden - - Resource not found
404 Not Found - - Conflict (e.g., version mismatch)
409 Conflict - - Rate limit exceeded
429 Too Many Requests - - Server error
500 Internal Server Error - - Service unavailable
503 Service Unavailable
Error response format:
json
{
"id": "request-id",
"innerException": null,
"message": "TF401019: The Git repository with name or identifier MyRepo does not exist or you do not have permissions for the operation you are attempting.",
"typeName": "Microsoft.TeamFoundation.Git.Server.GitRepositoryNotFoundException",
"typeKey": "GitRepositoryNotFoundException",
"errorCode": 0,
"eventId": 3000
}Azure DevOps API返回标准HTTP状态码:
- - 请求成功
200 OK - - 资源创建成功
201 Created - - 请求已接受(异步操作)
202 Accepted - - 请求成功,无返回内容
204 No Content - - 请求无效
400 Bad Request - - 需要认证
401 Unauthorized - - 权限不足
403 Forbidden - - 资源不存在
404 Not Found - - 冲突(例如版本不匹配)
409 Conflict - - 请求频率超限
429 Too Many Requests - - 服务器错误
500 Internal Server Error - - 服务不可用
503 Service Unavailable
错误响应格式:
json
{
"id": "request-id",
"innerException": null,
"message": "TF401019: The Git repository with name or identifier MyRepo does not exist or you do not have permissions for the operation you are attempting.",
"typeName": "Microsoft.TeamFoundation.Git.Server.GitRepositoryNotFoundException",
"typeKey": "GitRepositoryNotFoundException",
"errorCode": 0,
"eventId": 3000
}Rate Limiting
请求频率限制
Azure DevOps enforces rate limits:
- Global limit: Varies by service (typically 200-300 requests per minute)
- TSTUs (Team Services Time Units): Used to measure resource consumption
- Retry-After header: Indicates when to retry after 429 error
Best practices:
- Implement exponential backoff
- Respect header
Retry-After - Cache responses when appropriate
- Use batch operations when available
Azure DevOps实施请求频率限制:
- 全局限制: 因服务而异(通常为每分钟200-300次请求)
- TSTUs(Team Services时间单位): 用于衡量资源消耗
- Retry-After响应头: 429错误时指示重试等待时间
最佳实践:
- 实现指数退避重试机制
- 遵循响应头指示
Retry-After - 合理缓存响应结果
- 尽可能使用批量操作
Permissions & Scopes
权限与范围
PAT Scopes
PAT权限范围
When creating Personal Access Tokens, select appropriate scopes:
- Agent Pools: Read & manage
- Analytics: Read
- Audit: Read audit log
- Build: Read & execute
- Code: Full, Read, or Status
- Extensions: Read & manage
- Graph: Read
- Identity: Read
- Marketplace: Acquire, manage, publish
- Member Entitlement Management: Read & write
- Packaging: Read, write, & manage
- Project and Team: Read, write, & manage
- Release: Read, write, execute, & manage
- Secure Files: Read, create, & manage
- Service Connections: Read, query, & manage
- Symbols: Read
- Task Groups: Read, create, & manage
- Test Management: Read & write
- Tokens: Read & manage
- User Profile: Read & write
- Variable Groups: Read, create, & manage
- Work Items: Full, Read, & write
Important: Always use the least privileged scope required.
创建个人访问令牌时,选择合适的权限范围:
- Agent Pools: 读取与管理
- Analytics: 读取
- Audit: 读取审计日志
- Build: 读取与执行
- Code: 完全权限、只读或状态读取
- Extensions: 读取与管理
- Graph: 读取
- Identity: 读取
- Marketplace: 获取、管理、发布
- Member Entitlement Management: 读取与写入
- Packaging: 读取、写入与管理
- Project and Team: 读取、写入与管理
- Release: 读取、写入、执行与管理
- Secure Files: 读取、创建与管理
- Service Connections: 读取、查询与管理
- Symbols: 读取
- Task Groups: 读取、创建与管理
- Test Management: 读取与写入
- Tokens: 读取与管理
- User Profile: 读取与写入
- Variable Groups: 读取、创建与管理
- Work Items: 完全权限、只读与写入
重要提示: 始终使用满足需求的最小权限范围。
OAuth 2.0 Scopes
OAuth 2.0权限范围
For OAuth applications, use scopes in the format:
- - Work items (read)
vso.work - - Work items (write)
vso.work_write - - Code (read)
vso.code - - Code (write)
vso.code_write - - Build (read)
vso.build - - Build (execute)
vso.build_execute
对于OAuth应用,使用以下格式的权限范围:
- - 工作项(只读)
vso.work - - 工作项(可写)
vso.work_write - - 代码(只读)
vso.code - - 代码(可写)
vso.code_write - - 构建(只读)
vso.build - - 构建(可执行)
vso.build_execute
API Versioning
API版本控制
Azure DevOps APIs use explicit versioning:
Versions:
- - Latest stable (recommended)
7.1 - - Stable
7.0 - - Stable
6.0 - - Older stable
5.1 - Versions with suffix (e.g.,
-preview) - Preview features7.1-preview.1
Version format:
- - Latest patch of 7.1
api-version=7.1 - - Preview version 1 of 7.1
api-version=7.1-preview.1
Important:
- Always specify (required on all requests)
api-version - Preview APIs may change or be removed
- Use stable versions for production
- Monitor deprecation notices
Azure DevOps API使用显式版本控制:
版本类型:
- - 最新稳定版(推荐使用)
7.1 - - 稳定版
7.0 - - 稳定版
6.0 - - 旧版稳定版
5.1 - 带后缀的版本(例如
-preview)- 预览功能7.1-preview.1
版本格式:
- - 7.1的最新补丁版本
api-version=7.1 - - 7.1的第一个预览版本
api-version=7.1-preview.1
重要提示:
- 所有请求必须指定
api-version - 预览API可能会发生变更或被移除
- 生产环境请使用稳定版
- 关注弃用通知
Best Practices
最佳实践
Performance
性能优化
- Use batch operations when fetching multiple items
- Implement pagination for large result sets
- Use specific fields with where supported
$select - Cache responses when appropriate
- Use delta queries for incremental sync
- Leverage continuation tokens properly
- 获取多个资源时使用批量操作
- 对大数据集实现分页
- 支持的端点使用指定所需字段
$select - 合理缓存响应结果
- 使用增量查询实现增量同步
- 正确使用延续令牌
Security
安全
- Store PATs securely (use Azure Key Vault or similar)
- Use appropriate scopes (least privilege)
- Rotate PATs regularly (set expiration)
- Use HTTPS only
- Validate input to prevent injection
- Implement proper error handling
- Log security events
- Never commit PATs to source control
- 安全存储PAT(使用Azure Key Vault等工具)
- 使用最小必要权限范围
- 定期轮换PAT(设置过期时间)
- 仅使用HTTPS协议
- 验证输入防止注入攻击
- 实现完善的错误处理
- 记录安全事件
- 切勿将PAT提交到代码仓库
Development
开发
- Use latest stable API version
- Handle rate limits with retry logic
- Implement exponential backoff
- Check for preview API stability before using
- Monitor service health
- Use JSON Patch for updates
- Validate responses
- Handle pagination correctly
- Test with various edge cases
- Use descriptive error messages
- 使用最新稳定版API
- 处理频率限制时实现重试逻辑
- 实现指数退避机制
- 使用预览API前确认稳定性
- 监控服务健康状态
- 使用JSON Patch进行更新操作
- 验证响应结果
- 正确处理分页
- 测试各种边缘场景
- 使用描述性错误信息
Integration Patterns
集成模式
- Webhooks (Service Hooks): For event-driven integrations
- Polling: For batch processing (avoid excessive polling)
- Scheduled Jobs: For periodic sync operations
- Real-time sync: Using service hooks + API calls
- Webhooks(服务挂钩): 事件驱动型集成
- 轮询: 批量处理场景(避免过度轮询)
- 定时任务: 周期性同步操作
- 实时同步: 结合服务挂钩与API调用
Common Use Cases
常见使用场景
Create Work Item
创建工作项
http
POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/$Bug?api-version=7.1
Content-Type: application/json-patch+json
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "Critical bug in login flow"
},
{
"op": "add",
"path": "/fields/System.Description",
"value": "Users cannot log in with SSO"
},
{
"op": "add",
"path": "/fields/Microsoft.VSTS.Common.Priority",
"value": 1
}
]http
POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/$Bug?api-version=7.1
Content-Type: application/json-patch+json
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "Critical bug in login flow"
},
{
"op": "add",
"path": "/fields/System.Description",
"value": "Users cannot log in with SSO"
},
{
"op": "add",
"path": "/fields/Microsoft.VSTS.Common.Priority",
"value": 1
}
]Create Pull Request
创建拉取请求
http
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1
Content-Type: application/json
{
"sourceRefName": "refs/heads/feature/new-feature",
"targetRefName": "refs/heads/main",
"title": "Add new feature",
"description": "This PR adds the new feature",
"reviewers": [
{"id": "reviewer-id-1"},
{"id": "reviewer-id-2"}
]
}http
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1
Content-Type: application/json
{
"sourceRefName": "refs/heads/feature/new-feature",
"targetRefName": "refs/heads/main",
"title": "Add new feature",
"description": "This PR adds the new feature",
"reviewers": [
{"id": "reviewer-id-1"},
{"id": "reviewer-id-2"}
]
}Queue Build
触发构建
http
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=7.1
Content-Type: application/json
{
"definition": {
"id": 123
},
"sourceBranch": "refs/heads/main",
"parameters": "{\"param1\":\"value1\"}"
}http
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=7.1
Content-Type: application/json
{
"definition": {
"id": 123
},
"sourceBranch": "refs/heads/main",
"parameters": "{\"param1\":\"value1\"}"
}Run WIQL Query
执行WIQL查询
http
POST https://dev.azure.com/{organization}/{project}/_apis/wit/wiql?api-version=7.1
Content-Type: application/json
{
"query": "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.WorkItemType] = 'Bug' AND [System.State] = 'Active' AND [System.AssignedTo] = @Me ORDER BY [System.Priority] ASC"
}http
POST https://dev.azure.com/{organization}/{project}/_apis/wit/wiql?api-version=7.1
Content-Type: application/json
{
"query": "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.WorkItemType] = 'Bug' AND [System.State] = 'Active' AND [System.AssignedTo] = @Me ORDER BY [System.Priority] ASC"
}Create Service Hook Subscription
创建服务挂钩订阅
http
POST https://dev.azure.com/{organization}/_apis/hooks/subscriptions?api-version=7.1
Content-Type: application/json
{
"publisherId": "tfs",
"eventType": "workitem.updated",
"resourceVersion": "1.0",
"consumerId": "webHooks",
"consumerActionId": "httpRequest",
"publisherInputs": {
"projectId": "{projectId}",
"workItemType": "Bug"
},
"consumerInputs": {
"url": "https://example.com/webhook",
"httpHeaders": "Content-Type:application/json"
}
}http
POST https://dev.azure.com/{organization}/_apis/hooks/subscriptions?api-version=7.1
Content-Type: application/json
{
"publisherId": "tfs",
"eventType": "workitem.updated",
"resourceVersion": "1.0",
"consumerId": "webHooks",
"consumerActionId": "httpRequest",
"publisherInputs": {
"projectId": "{projectId}",
"workItemType": "Bug"
},
"consumerInputs": {
"url": "https://example.com/webhook",
"httpHeaders": "Content-Type:application/json"
}
}Tools & Testing
工具与测试
REST Client Tools
REST客户端工具
- Postman - Popular API testing tool
- curl - Command-line tool
- PowerShell -
Invoke-RestMethod - Python - library
requests - Azure DevOps CLI - Official CLI tool
- Postman - 流行的API测试工具
- curl - 命令行工具
- PowerShell - 使用
Invoke-RestMethod - Python - 使用库
requests - Azure DevOps CLI - 官方命令行工具
Azure DevOps CLI
Azure DevOps CLI
Install and use the official CLI:
bash
undefined安装并使用官方命令行工具:
bash
undefinedInstall
Install
pip install azure-devops
pip install azure-devops
Login
Login
az devops login --organization https://dev.azure.com/{organization}
az devops login --organization https://dev.azure.com/{organization}
Configure defaults
Configure defaults
az devops configure --defaults organization=https://dev.azure.com/{organization} project={project}
az devops configure --defaults organization=https://dev.azure.com/{organization} project={project}
Examples
Examples
az repos list
az pipelines build list
az boards work-item create --title "Bug" --type Bug
undefinedaz repos list
az pipelines build list
az boards work-item create --title "Bug" --type Bug
undefinedTesting Authentication
测试认证
Test PAT authentication:
bash
undefined测试PAT认证:
bash
undefinedEncode PAT
Encode PAT
PAT_ENCODED=$(echo -n ":YOUR_PAT" | base64)
PAT_ENCODED=$(echo -n ":YOUR_PAT" | base64)
Test
Test
curl -H "Authorization: Basic $PAT_ENCODED"
"https://dev.azure.com/{organization}/_apis/projects?api-version=7.1"
"https://dev.azure.com/{organization}/_apis/projects?api-version=7.1"
undefinedcurl -H "Authorization: Basic $PAT_ENCODED"
"https://dev.azure.com/{organization}/_apis/projects?api-version=7.1"
"https://dev.azure.com/{organization}/_apis/projects?api-version=7.1"
undefinedSDKs Available
可用SDK
- .NET - ,
Microsoft.TeamFoundationServer.ClientMicrosoft.VisualStudio.Services.Client - Node.js -
azure-devops-node-api - Python -
azure-devops - Java - Azure DevOps SDK for Java
- .NET - ,
Microsoft.TeamFoundationServer.ClientMicrosoft.VisualStudio.Services.Client - Node.js -
azure-devops-node-api - Python -
azure-devops - Java - Azure DevOps Java SDK
Progressive Loading
渐进式学习
This skill provides comprehensive coverage of Azure DevOps API. For specific tasks:
- Identify the service area (Boards, Repos, Pipelines, Test, Artifacts)
- Find the relevant section in this document
- Use the API reference for detailed parameter information
- Test with Azure DevOps CLI or REST client before implementing
本指南全面覆盖Azure DevOps API。针对特定任务:
- 确定服务领域(Boards、Repos、Pipelines、测试、制品)
- 在文档中找到对应章节
- 参考API文档获取详细参数信息
- 在实现前使用Azure DevOps CLI或REST客户端测试
Reference Links
参考链接
- Official Docs: https://docs.microsoft.com/rest/api/azure/devops/
- API Reference: https://docs.microsoft.com/rest/api/azure/devops/?view=azure-devops-rest-7.1
- Authentication: https://docs.microsoft.com/azure/devops/integrate/get-started/authentication/authentication-guidance
- Service Hooks: https://docs.microsoft.com/azure/devops/service-hooks/overview
- Rate Limits: https://docs.microsoft.com/azure/devops/integrate/concepts/rate-limits
- API Versioning: https://docs.microsoft.com/azure/devops/integrate/concepts/rest-api-versioning
- Azure DevOps CLI: https://docs.microsoft.com/cli/azure/devops
- Node.js SDK: https://github.com/microsoft/azure-devops-node-api
- Python SDK: https://github.com/microsoft/azure-devops-python-api
- Status Page: https://status.dev.azure.com/
- 官方文档: https://docs.microsoft.com/rest/api/azure/devops/
- API参考: https://docs.microsoft.com/rest/api/azure/devops/?view=azure-devops-rest-7.1
- 认证指南: https://docs.microsoft.com/azure/devops/integrate/get-started/authentication/authentication-guidance
- 服务挂钩: https://docs.microsoft.com/azure/devops/service-hooks/overview
- 频率限制: https://docs.microsoft.com/azure/devops/integrate/concepts/rate-limits
- API版本控制: https://docs.microsoft.com/azure/devops/integrate/concepts/rest-api-versioning
- Azure DevOps CLI: https://docs.microsoft.com/cli/azure/devops
- Node.js SDK: https://github.com/microsoft/azure-devops-node-api
- Python SDK: https://github.com/microsoft/azure-devops-python-api
- 服务状态页: https://status.dev.azure.com/
API URL Patterns
API URL模式
Different Azure DevOps services use different base URLs:
- Core services:
https://dev.azure.com/{organization}/ - Release Management:
https://vsrm.dev.azure.com/{organization}/ - Package Management:
https://feeds.dev.azure.com/{organization}/ - Identity:
https://vssps.dev.azure.com/{organization}/ - Analytics:
https://analytics.dev.azure.com/{organization}/
不同Azure DevOps服务使用不同的基础URL:
- 核心服务:
https://dev.azure.com/{organization}/ - 发布管理:
https://vsrm.dev.azure.com/{organization}/ - 包管理:
https://feeds.dev.azure.com/{organization}/ - 身份管理:
https://vssps.dev.azure.com/{organization}/ - 分析服务:
https://analytics.dev.azure.com/{organization}/
Notes
注意事项
- This skill covers the Azure DevOps REST API version 7.1 (latest stable)
- Some endpoints may require preview API versions
- Always check the official documentation for latest changes
- API versions and endpoints may evolve over time
- Rate limits and throttling policies apply
- Proper authentication and permissions are required for all operations
- Some features are only available in Azure DevOps Services, not Server
- 本指南覆盖Azure DevOps REST API 7.1版本(最新稳定版)
- 部分端点可能需要使用预览版API
- 始终参考官方文档获取最新变更
- API版本与端点可能会随时间演进
- 适用频率限制与节流策略
- 所有操作均需正确的认证与权限
- 部分功能仅在Azure DevOps Services中可用,Azure DevOps Server不支持