简体   繁体   English

在Azure Logic应用中调用多部分/表单数据REST服务

[英]Calling multipart/form-data REST service in Azure Logic Apps

I have made a workflow using Http Listener and Http actions in Azure Logic Apps. 我已经在Azure Logic Apps中使用Http侦听器和Http操作制作了工作流。 Listener is to catch POST request and Http action has details of my api which is hosted over azure web app. 侦听器将捕获POST请求,并且Http操作包含我的API的详细信息,该API托管在Azure Web应用程序上。 Request is multipart/form-data type and posts a file along with 3 other string values. 请求是多部分/表单数据类型,并与其他3个字符串值一起发布文件。

My problems are 我的问题是

  1. If I'm explicitly setting content type header as multipart/form-data in Http action, it is not passing any boundary to api controller and my api is giving error "request was rejected because no multipart boundary was found". 如果我在Http操作中将内容类型标头明确设置为multipart / form-data,则它没有将任何边界传递给api控制器,并且我的api给出了错误“请求被拒绝,因为未找到多部分边界”。
  2. If I'm trying to pass @triggers().outputs.body.ContentType as header of my http action, I'm getting this error: 如果我尝试将@triggers().outputs.body.ContentType传递为我的http操作的标头,则出现此错误:

{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'http' inputs at line '1' and column '11': 'Error converting value \\"multipart/form-data; {“ code”:“ InvalidTemplate”,“ message”:“在行'1'和列'11'的操作'http'输入中无法处理模板语言表达式:'错误转换值\\” multipart / form-data; boundary=----WebKitFormBoundaryi3knGy6dh92BdKdr\\" to type 'Microsoft.WindowsAzure.ResourceStack.Common.Collections.InsensitiveDictionary`1[System.String]'. Path 'headers'.'."} boundary = ---- WebKitFormBoundaryi3knGy6dh92BdKdr \\“键入“ Microsoft.WindowsAzure.ResourceStack.Common.Collections.InsensitiveDictionary`1 [System.String]'。路径为“标头”。”。

Please help, how can I pass content type and boundary both to my api using Http action? 请帮忙,如何使用Http操作将内容类型和边界都传递给我的api?

The headers object in the Logic app definition is a JSON object with keys and values. Logic应用程序定义中的headers对象是带有键和值的JSON对象。 Specifically, if you want to pass the content-type header like above your object definition in the code view would look like: 具体来说,如果您想像上面那样传递content-type标头,则在代码视图中的对象定义将类似于:

"MyAction" : {
  "type" : "http",
  "inputs" : {
    "headers" : {
      "Content-type" : "@triggerBody().ContentType"
    },
    "body" : … rest of properties here …

Hopefully this is why your API isn't getting the boundary either. 希望这就是为什么您的API也不限制边界的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM