Power Automate多文件上传审批流报错:无法选取JSON的body属性
Power Automate审批流程报错解决方案
问题核心
报错原因是你在循环中同时引用了三个Parse JSON动作的输出,但这三个动作不会同时执行:比如用户选择bulk时,处理Individual上传的Parse JSON根本没运行,此时outputs('Parse_JSON')为空,自然无法找到body属性。
解决步骤
1. 统一合并有效文件链接数组
在所有条件分支执行完毕后,添加一个Compose动作,用以下表达式合并实际存在的文件上传数组(未执行的分支用空数组替代,避免空引用):
union( if(equals(outputs('Get_response_details')?['body/站点选择字段内部名'], 'Individual'), outputs('Parse_JSON')?['body'], createArray()), if(equals(outputs('Get_response_details')?['body/站点选择字段内部名'], 'bulk'), outputs('Parse_JSON_1')?['body'], createArray()), if(and(equals(outputs('Get_response_details')?['body/站点选择字段内部名'], 'bulk'), greaterOrEquals(int(coalesce(outputs('Get_response_details')?['body/rb831dd7ae5414e028d092e4890fb783a'],'0')),10)), outputs('Parse_JSON_2')?['body'], createArray()) )
替换表达式中的「站点选择字段内部名」为你表单中对应问题的实际内部字段名(可从
Get response details的输出中查看)
2. 生成审批详情文本
再添加一个Compose动作,将合并后的数组转换为每行一个链接的文本格式,方便插入审批详情:
join(outputs('Compose_合并文件数组'), decodeUriComponent('%0A'))
3. 调整审批动作配置
删除自动生成的三个For Each循环,直接将第二个Compose的输出插入到「Start and wait for an approval」的详情字段中,无需循环即可展示所有文件链接。
4. 校验Parse JSON Schema
确保每个Parse JSON的Schema与Microsoft Forms文件上传的输出格式匹配,示例Schema如下:
{ "type": "array", "items": { "type": "object", "properties": { "name": {"type": "string"}, "link": {"type": "string"}, "id": {"type": "string"}, "type": {}, "size": {"type": "integer"}, "referenceId": {"type": "string"}, "driveId": {"type": "string"}, "status": {"type": "integer"}, "uploadSessionUrl": {} }, "required": ["name","link","id","type","size","referenceId","driveId","status"] } }
Schema错误会导致Parse JSON输出空的body,同样引发报错。
调整后流程顺序
- When a new response is submitted(触发)
- Get response details(获取响应)
- 条件1(判断站点类型):
- 真:执行
Parse JSON(处理Individual上传) - 假:执行
Parse JSON_1(处理Bulk首次上传);触发条件2判断站点数≥10,真则执行Parse JSON_2(处理溢出上传)
- 真:执行
- Compose(合并文件数组)
- Compose(生成审批详情文本)
- Start and wait for an approval(插入审批详情文本)
- Post a message to Teams chat or channel
内容的提问来源于stack exchange,提问作者confused_Zebra
相关产品推荐
相关产品推荐

