使用从HTTP请求到另一个Azure的响应数据

时间:2019-05-15 11:18:20

标签: azure azure-logic-apps

我正在Azure中设计一个Logic App,有什么办法可以发出这样的两个HTTP请求: 1.我正在呼叫我的Identity Server 4以获取新的访问令牌 2.我想从第一个请求中获取访问令牌,将其放到标头中,并用它调用.Net Core Api端点?

谢谢

2 个答案:

答案 0 :(得分:1)

根据我的理解,您想知道如何从JSON对象获取access_token值,该对象来自get token http request的响应。 我为您做了一个简单的演示: enter image description here

职位要求的详细信息: enter image description here

这是在Azure中获取访问令牌的简单请求。响应将是:

{
    "token_type": "Bearer",
    "expires_in": "3600",
    "ext_expires_in": "3600",
    "expires_on": "1557995356",
    "not_before": "1557991456",
    "resource": "<-resource name->",
    "access_token": "<-value of access token->"
}

如您所见,此逻辑应用程序是由http请求触发的,它将执行发布请求以获取包含access_token的JSON对象。最后,它将在response中返回access_token值。

所以这里的关键是如何配置,以便我们可以从step2的JSON响应中获取access_token值。

让我们打开逻辑应用程序代码视图,找到“响应” =>“ body”并将其值修改为:“ @ body('HTTP')。access_token”

enter image description here

这样您就可以从上一个http请求的JSON响应中获取某些参数: enter image description here

答案 1 :(得分:0)

您可以使用Parsing JSON操作来使用第一个请求的响应。 enter image description here