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

Azure Pipeline REST API无法接收请求体中的列表类型参数

问题原因及解决方案

问题出在请求体中使用了templateParameters字段传递管道参数,Azure DevOps构建排队REST API里,管道自身定义的顶层parameters(即你YAML中声明的参数),需要通过parameters字段传递,而非templateParameters——后者仅用于管道引用的外部模板文件中的参数。

另外,BoxNames这类object类型的数组参数,传递格式要匹配YAML定义,但核心问题还是字段使用错误。同时需要注意:parameters字段的值必须是序列化后的JSON字符串,不能直接传对象结构,这是Azure DevOps API的硬性要求(字符串参数用templateParameters时能生效是特殊兼容逻辑,object类型参数不支持)。

修改后的请求体示例

var requestBody = new
{
    definition = new
    {
        id = 234,
    },
    project = new
    {
        id = xxxx
    },
    sourceBranch = "main",
    parameters = System.Text.Json.JsonSerializer.Serialize(new
    {
        BoxNames = new List<string> { "name1" },
        id = "yyyy"
    })
};

关键修改点

  • 替换templateParameters字段为parameters
  • 将参数对象序列化为JSON字符串(可使用System.Text.Json或Newtonsoft.Json实现)

这样修改后,管道就能正确读取你传入的自定义参数,不再使用默认值。

内容的提问来源于stack exchange,提问作者akshay Sharma

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 03:42:33