通过APIM提交文件到Logic App处理时HTTP触发器的JSON schema如何配置
Logic App HTTP触发器Request JSON schema配置方案
根据你提供的swagger定义,你的接口是multipart/form-data格式的POST请求,携带必填的transactionId请求头和employeefile文本文件表单参数,你可以直接用以下JSON作为Request触发器的schema配置:
{ "type": "object", "properties": { "headers": { "type": "object", "properties": { "transactionId": { "type": "string", "format": "uuid" } }, "required": ["transactionId"] }, "formData": { "type": "object", "properties": { "employeefile": { "type": "object", "properties": { "content": { "type": "string" }, "contentType": { "type": "string", "pattern": "^text/plain.*" }, "fileName": { "type": "string" } }, "required": ["content", "contentType", "fileName"] } }, "required": ["employeefile"] } }, "required": ["headers", "formData"] }
配置说明
- 填写上述schema后,触发器会自动对入参做合法性校验:请求头缺少
transactionId、格式不是UUID、表单缺少employeefile、文件类型不是text/plain的请求会被直接拦截返回400错误,不需要你额外编写校验逻辑。 - 后续在Logic App工作流中读取文本文件内容时,直接使用表达式
triggerBody()?['formData']?['employeefile']?['content']即可获取到完整的文本内容,无需额外解码操作。 - 如果你不需要自动校验入参,也可以直接留空
Request JSON schema字段,触发器会接收所有格式的请求,你可以在后续步骤中自行提取所需参数。 - APIM侧直接将请求原样透传给Logic App的触发URL即可,无需额外做报文转换,只需确保
transactionId请求头被正常转发。
内容的提问来源于stack exchange,提问作者Nathan
相关产品推荐
相关产品推荐

