Microsoft Power Automate流报错:Parse_JSON操作失败(MS Form可选文件未上传)
解决Power Automate中Parse_JSON因可选文件为空报错的问题
报错信息
Action 'Parse_JSON' failed
详情:
Unable to process template language expressions in action 'Parse_JSON' inputs at line '0' and column '0': 'Required property 'content' expects a value but got null. Path ''.'.
问题原因
当MS Form的可选文件上传问题未填写时,传入Parse_JSON的content参数为null,而Parse_JSON要求该属性必须有值,导致流中断。
解决方法
方法1:为Parse_JSON的Content参数添加空值判断
在Parse_JSON的Content输入框中,使用表达式判断文件内容是否为空,为空时传入默认空JSON对象:
if(empty(triggerBody()?['file_upload_field_name']), '{}', triggerBody()?['file_upload_field_name'])
替换file_upload_field_name为你MS Form中文件上传问题的实际字段名
方法2:添加条件分支,按需执行Parse_JSON
- 在Parse_JSON动作前添加条件控件,判断文件上传字段是否非空:
- 条件表达式:
not(empty(triggerBody()?['file_upload_field_name']))
- 条件表达式:
- 将Parse_JSON及后续依赖文件内容的操作放在如果是分支
- 如果否分支中添加无文件场景的适配逻辑(如直接跳过或设置默认值)
方法3:修改Parse_JSON的Schema,允许content为null
编辑Parse_JSON的Schema,调整字段规则允许空值。例如原Schema:
{ "type": "object", "properties": { "content": { "type": "string" } }, "required": ["content"] }
修改为:
{ "type": "object", "properties": { "content": { "type": ["string", "null"] } } }
这样Schema允许content为null或字符串,Parse_JSON不会因空值报错。
内容的提问来源于stack exchange,提问作者Teaquell
相关产品推荐
相关产品推荐

