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

ADF流程中Web Activity无法解析数组变量VariOutput报错求助

解决ADF Web Activity数组变量序列化错误问题
  • 错误原因:你的Web Activity请求体中,ErrorMessage字段的表达式未将拼接结果用双引号包裹,导致生成的JSON结构非法。当string(variables('VariOutput'))把数组转为["file1","file2"]格式的字符串后,直接拼入JSON会变成:

    "ErrorMessage":File/Files not found-["file1","file2"]
    

    这不符合JSON语法(字符串值未被引号包裹),因此Web服务无法反序列化请求内容。

  • 解决方案1:给表达式结果添加引号
    修改Web Activity的请求体代码,将ErrorMessage的表达式放在双引号内:

    {
      "RunId":"Dummy",
      "applicationName": "@{pipeline().parameters.AppName}",
      "ErrorCode":"error",
      "ErrorMessage": "@{concat('File/Files not found-', string(variables('VariOutput')))}"
    }
    

    生成的JSON中ErrorMessage的值会被正确包裹为字符串,格式合法。

  • 解决方案2:用ADF内置函数构建JSON(更稳妥)
    利用createObject函数自动处理JSON序列化,避免手动拼接出错:

    @{createObject(
        'RunId', 'Dummy',
        'applicationName', pipeline().parameters.AppName,
        'ErrorCode', 'error',
        'ErrorMessage', concat('File/Files not found-', string(variables('VariOutput')))
    )}
    

    这种方式会自动处理所有字段的引号和转义,即使参数包含特殊字符也能保证JSON格式正确。

内容的提问来源于stack exchange,提问作者Avenue Guy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 11:50:20