简体   繁体   English

将一个 Http 请求的响应数据传递给 Azure 逻辑应用程序中的另一个 Http 请求

[英]Pass response data of one Http request to another Http request in Azure Logic Apps

I am building a logic apps where I need to pass response data of one Http request to another Http request in Azure Logic Apps.我正在构建一个逻辑应用程序,我需要将一个 Http 请求的响应数据传递给 Azure 逻辑应用程序中的另一个 Http 请求。

The first Http request is POST method and is returning this data.第一个 Http 请求是 POST 方法并返回此数据。

{
  "ID": "892069751085535232",
  "Name": "Test",  
  "source": "retailcloud",
  "metadata": {
    "OrderID": "894",
    "DeviceID": "123"
  }
}

The next will be again POST request with something like this data.接下来将再次使用类似此数据的 POST 请求。

{
  id: response.id,
  order_id: response.metadata.OrderId
}

How I can pass here Id and OrderId?我如何在这里传递 Id 和 OrderId? Like which Logic app inbuild functions i need to use here?比如我需要在这里使用哪些 Logic 应用内置功能?

Here I am using 2 Connectors one is When HTTP request is received and the other is HTTP Connectors.我在这里使用 2 个连接器,一个是When HTTP request is received ,另一个是HTTP连接器。

In order to make your properties available for next Connector I am just adding the sample pay load.为了使您的属性可用于下一个连接器,我只是添加示例有效载荷。在此处输入图像描述

Then paste your sample payload to the area and click done.然后将您的示例负载粘贴到该区域并单击完成。 You ll have a generated schema for your payload您将为您的有效负载生成一个架构

在此处输入图像描述

Then add the Http Connector and add the method and url. For the ID and OrderID properties to get passed you need to add the properties to the body which are automatically generated when you click Dynamic Contents .然后添加Http连接器并添加方法和 url。要传递 ID 和 OrderID 属性,您需要将属性添加到主体中,这些属性在您单击Dynamic Contents时自动生成。

在此处输入图像描述

Let's say your first HTTP action is called HTTP1 and the second HTTP action is called HTTP2 .假设您的第一个 HTTP 操作称为HTTP1 ,第二个 HTTP 操作称为HTTP2

You have 2 options.你有两个选择。

  1. add a Parse JSON action between them, use the output of HTTP1 as a content, and use sample payload to generate schema.在它们之间添加一个Parse JSON动作,使用HTTP1的output作为内容,使用sample payload生成schema。 Then you can use dynamic content from this action in HTTP2 :然后您可以在HTTP2中使用来自此操作的动态内容:

    { "id": <ID from Parse JSON>, "order_id": <OrderID from Parse JSON> }

  2. do not add 'Parse JSON' - and use an Expression instead of the Dynamic content in the body of HTTP2 :不要添加“解析 JSON”——并在HTTP2的正文中使用表达式而不是动态内容:

    { "id": <body('HTTP1')?['ID']>, "order_id": <body('HTTP1')?['metadata']?['OrderID']> }

Ignore the angle brackets in the examples above - replace them with the actual dynamic content or with the expression as needed.忽略上面示例中的尖括号 - 将它们替换为实际的动态内容或根据需要替换为表达式。

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

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