是否有(简单)方法从HTTP标头参数中提取子字符串?

问题描述 投票:0回答:1

我正在使用分页调用rest api,在响应中我得到HTTP Header中的“next”链接,格式如下:Link <https://aaaaaa/bbb/ccc/ddd/version/2.1.1/locations/?date_from=1601-01-01T00%3a00%3a00Z&date_to=2019-04-24T17%3a03%3a29Z&offset=100&limit=100>;为rel = “下一步”

我可以轻松获取HTTP Header链接参数的值

但Azure Logic Apps中没有正则表达式,我可以使用它来进一步解析<和>之间的链接值

一种选择是编写一个处理此问题的Azure函数,但我正在寻找更简单的东西(如果可能的话)

{
    "inputs": {
        "name": "newLink",
        "value": "@{outputs('HTTP')['headers']?['Link']}"
    }
}

newLink变量现在包含链接的完整值。但我只需要<和>之间的部分

任何有关如何将newLink变量解析为我需要的提示(不使用azure函数)的提示都非常受欢迎。

azure-logic-apps
1个回答
3
投票

您可以使用spilt()函数,如下所示:

@split(split(triggerOutputs()['headers']?['Link'],'<')[1],'>')[0]

设计师视图

Designer

代码视图

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Response": {
                "inputs": {
                    "body": "@split(split(triggerOutputs()['headers']?['Link'],'<')[1],'>')[0]",
                    "statusCode": 200
                },
                "kind": "Http",
                "runAfter": {},
                "type": "Response"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    }
}

邮差:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.