如何从http触发的逻辑应用程序解析xml?

时间:2019-05-16 20:29:02

标签: azure azure-logic-apps

如何提取逻辑应用程序内部收到的请求的内容

我有一个常规的http触发逻辑应用程序,如下所示:

enter image description here

我正在通过邮递员向其发送POST请求,如下所示:

enter image description here

{
    "$content-type": "application/octet-stream",
    "$content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><cases><file-path>yes</file-path></cases>"
}

我正在尝试提取$content有效载荷:

"@{string(xml(string(triggerBody()?['content'])))}"

我遇到的问题是:

enter image description here

如何提取逻辑应用程序内部收到的请求的内容

这是整个初始化变量步骤:

    "Initialize_variable": {
        "inputs": {
            "variables": [
                {
                    "name": "contentOfRequest",
                    "type": "String",
                    "value": "@{string(xml(string(triggerBody()?['content'])))}"
                }
            ]
        },
        "runAfter": {},
        "type": "InitializeVariable"
    }

1 个答案:

答案 0 :(得分:1)

由于请求正文为字符串,因此不支持select属性。因此,您首先需要解析为Json格式,然后就可以选择$content

enter image description here

关于如何获取Json架构,只需在Use sample payload to generate schema操作中单击Parse Json并粘贴您的Json数据,然后单击完成即可。

然后使用$content提取body('Parse_JSON')?['$content']值,这样您将获得内容值。

enter image description here

相关问题