Latest Posts

How to handle HTTP request in Logic apps


In this article, we are going to see how you can handle HTTP requests in logic apps and use the response from that request in the subsequent action of the logic app flow.

Requirement:

Here, we are going to see how we can trigger the Logic app flow using an HTTP request from another Logic app.

Note: You can trigger an HTTP request from, another logic app, Azure Data Factory, or any application that can trigger an HTTP request.

Implementation:

We will create a flow (Parent Logic app) that can be triggered manually. This flow will trigger another flow (Child Logic app).

Create a Child Logic app

  1. First will create a child logic app flow
  2. Keep the trigger (When an HTTP request is received) as mentioned in the below screenshot. This is an incoming API call that could use actions in a Logic App or other API to trigger this flow.
  3. When a HTTP request is received
  4. You can see the trigger added in the flow.
  5. http request trigger added in flow
  6. Click on the green bar to expand it. You can see a highlighted text in the below screenshot.URL will be generated after saving. That means once you save this logic app, a URL will be generated, and that URL will be used to trigger this flow.
  7. URL will be generated after save
  8. As a next step and just to save flow, I have added a Send email notification. Save the flow.
  9. Send an email notification action
  10. Now if you expand the first step, you will be able to see a URL generated in the textbox, highlighted below. Just COPY this URL. This will be used in our Parent Flow.
  11. HTTP POST URL

Create a Parent Logic App

  1. Now, create another logic app. This logic app is going to be a Manual trigger (for demo purposes). You can choose the trigger according to your requirements. In the next step, add HTTP
  2. add HTTP action
  3. Now expand the HTTP action and as shown in the screenshot, select the Method as POST. Enter the URI that you had copied from the earlier Logic app (Child Logic app). Save the flow.
  4. POST method and HTTP URI

Test your Logic App

  1. Go to the logic app. Run the Parent Logic app manually.
  2. After some time, you will be able to see the output of your Child Logic app. You can also check the History of the Logic app.

Pass the parameter in HTTP Request

  • As this is for demo purpose, we will keep it simple only. Open the Parent Logic App.
  • Open the HTTP action.
  • In the Body section, you need to pass your parameters as shown in the screenshot. You can pass the parameters as per your requirement.
  • Pass the parameter in HTTP Request
  • In the body section I have passed the below parameters.{

"FirstName": "Mike",

"Lastname": "Tyson"

}

  • After this, go to your child logic app >> Open the action When the HTTP request is received, and click on Use sample payload to generate schema.
  • http request sample payload to generate schema
  • Paste the sample JSON here and click on Done.
  • sample payload
  • Create a string variable now and you can use the parameters as shown in the screenshot. Again, this is a simple demonstration of how to use parameters, but the actual implementation might be complicated.
  • use params for value

We value your Feedback:

Page URL:

Name:

 

Email:

 
 

Suggestion:

 

© 2024 Code SharePoint