You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps REST API List Items设Full recursion仅返回根目录的问题

关于Azure DevOps Git Items List接口仅返回根目录的问题

我尝试使用Azure DevOps的Git Items List接口拉取仓库中的所有文件,调用的URL如下:

https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repo id}/items?scopePath=/&recursionLevel=Full&api-version=7.0

但接口仅返回根路径的单个条目:

{
    "count":1
    ,"value":
    [
        {
            "objectId":"64ad7e9229fc73509cadae9e545ed620a5d00846"
            ,"gitObjectType":"tree"
            ,"commitId":"8323c75114f5d06a156819358744a4fa3b9788d1"
            ,"path":"/"
            ,"isFolder":true
            ,"url":"https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repo}/items?path=%2F&versionType=Branch&versionOptions=None"
        }
    ]
}

测试情况

  • 仓库中确实存在文件
  • 在不同项目的多个仓库中测试,结果一致
  • 曾尝试拉取子文件夹,怀疑触发数据上限,但结果仍仅返回所选文件夹的根目录
  • 其他REST API可正常工作:能够获取所有仓库、所有签入记录以及指定签入的变更记录
  • 我拥有系统管理员权限

补充发现

  • 参数似乎不区分大小写
  • 无效或虚构参数会被忽略(例如添加&breakme=true不会返回错误信息)
  • 添加IncludeContentMetadata参数测试后,调用URL:
https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repo id}/items?recursionLevel=full&IncludeContentMetadata=true&breakme=true&api-version=7.0

返回结果依然只有根目录条目:

{
    "count": 1,
    "value":
    [
        {
            "objectId": "4fc34171cbcaf49141b45c3b9096c101a879c181",
            "gitObjectType": "tree",
            "commitId": "d43240daf04466e8fbbbb414e5ddd3dcf8a042d1",
            "path": "/",
            "isFolder": true,
            "contentMetadata":
            {
                "fileName": ""
            },
            "url": "https://dev.azure.com/{org}/{project}/_apis/git/repositories/{repo}/items?path=%2F&versionType=Branch&versionOptions=None"
        }
    ]
}

疑问

为何接口仅返回根目录?有什么解决思路吗?


内容的提问来源于stack exchange,提问作者Alex Eisenhart

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 14:10:20