VSTS (Visual Studio Team Services) 是微软提供的 DevOps 平台(现更名为 Azure DevOps),用于项目管理、代码托管、持续集成/交付(CI/CD)等。REST API 是其提供的标准化接口,允许开发者通过 HTTP 请求与平台交互,实现自动化操作(如创建任务、拉取代码、触发构建等)。VSTS 扩展 则是通过自定义插件或工具扩展平台功能的模块。
_apis/wit/workitems
)。_apis/git/repositories
)。_apis/build/builds
)。WorkItems.ReadWrite
)。$top
和 $skip
分页:$top
和 $skip
分页:Accept-Encoding: gzip
。vss-extension.json
)错误。import requests
# 获取项目列表
url = "https://dev.azure.com/{org}/_apis/projects"
headers = {"Authorization": f"Bearer {PAT}"}
response = requests.get(url, headers=headers)
print(response.json())
# 创建工作项
payload = [{
"op": "add",
"path": "/fields/System.Title",
"value": "Fix API bug"
}]
response = requests.patch(
"https://dev.azure.com/{org}/{project}/_apis/wit/workitems/$Task?api-version=6.0",
json=payload,
headers={"Content-Type": "application/json-patch+json", **headers}
)