Accept HTTP Requests in a Flow and send Response back | Power Automate

Let’s say you want to create a consumable HTTP service, do some operation and send back Response. Here’s what you can do.

You can create an HTTP Request Trigger to receive the HTTP request, process the request and send back a Response.

Accept HTTP Request in Flow

Let’s create a listener first, so that we can get the URL to be used and ask users to submit on that URL.

  1. In your connectors, select the below connector ‘When an HTTP request is received


  2. This will let you accept HTTP requests of different methods. First, let’s just create the schema. Assuming you know what schema you are accepting, click on ‘Use sample payload to generate schema‘.


  3. Now, enter your sample data and click Done.


  4. Schema will be generated automatically.

  5. Now, save your Flow so that a URL could be generated.


  6. Also, remember to select what type of Request to accept. It’s under the Show advanced options

  7. Select what type of HTTP request this is. In this example, I’m accepting a POST request.

    relativePath is used when you want to access a specific resource in your HTTP request that is passed in the query string. None in my case, hence, not using it.
  8. Supported verbs in the HTTP Request trigger are GET, PUT, POST, PATCH, DELETE –

Process Info

This is subjective and is completely based on your use case, you can decide what you want to do with the data you receive. Could be anything!! I’ll simply highlight in short what I’m doing here.

I’m just accepting all “Requests” entity data and giving back a Reference ID to customer telling them that their request has been registered with us. Like a typical Ticketing system where you log a ticket and you get back a reference number.

In my example, I’m simply creating a CDS record in my D365 environment and I will return the Auto-generated field value to the Response so that it can be sent back to the caller.

In case you are also looking to create an Autonumber field for yourself in CDS, you can check this post – AutoNumber field in CDS | PowerApps

Send Back Response

Now, in the step above, I’ve created a CDS record in the system. It will also auto-generate a number for the record. I’ll use the same to pass it back as a response.

  1. Now, search for Response (or rather Request) in the Connectors list and you’ll be able to choose the Response action.


  2. In the same, you can then choose what Response code you want to return. This will differ based on where you use this. Example, if you use this Response Action in case of some error, you can return 500 or 404 if something was not found, depends.
    In this case, I’m returning 200 OK and the JSON of my message and sending back the Token (Auto-number field on Request entity record creation)

  3. Here, my Flow is complete.

Testing the Flow

Understand the building blocks of the Flow. Accept Request –> Process –> Response.

Now, the URL we get when we save the Flow is the one that goes to the developers/consumers.
It contain some tokens and header information.

See how I tested it using Postman.

  1. Once I copied it from the Flow and pasted in Postman, the Headers were populated automatically in Postman. (And then you can use this to build your code later on)


  2. Now, I am sending the data in the body in the following way

  3. Now, let’s say I submit the request using Postman.
    A record will be created in my D365 (Common Data Service)

  4. And the Token that the record generated will be returned as response back to Postman

    With the status of 200 OK

  5. And that’s how you can receive HTTP requests and send back responses using Flow in Power Automate.

Here are some more Power Automate / Flow posts you might want to look at

  1. Make HTTP request from Flow in Power Automate
  2. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  3. Terminate a Flow with Failed/Cancelled status | Power Automate
  4. Adaptive Cards for Teams to collect data from users using Power Automate | SharePoint Lists
  5. BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
  6. ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
  7. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  8. Pause a Flow using Delay and Delay Until | Power Automate
  9. Get Count of records retrieved in CDS connector in a Flow | Power Automate
  10. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  11. Switch-Case in a Flow | Power Automate
  12. Using Parse JSON to read individual List Records in Flow|Power Automate

Hope this was useful! 🙂

Advertisement

Make HTTP request from Flow in Power Automate

One of the most common asks I’ve come across lately is people asking whether or not, we can make external HTTP requests using Flow in Power Automate. Well, yes! Let’s quickly take a look at how you can do that.

Scenario

To keep the example really simple, I have an API that I can use to call to get weather information. (By the way, you’ll find MSN Weather connector in Power Automate too)
So, the API I’m using to test the call is OpenWeatherMap. Their API is really easy to understand for this example.

Note: You can create your account here and you’ll get an API key which you can use.

  1. Now, Let’s say I have the API key and I’m ready to consume their API.
    You can have your Flow start any which way you want, I’m just running it on schedule –
    Select HTTP in the search and select the HTTP trigger
    selectAction
  2. Now, I can fill in the data required to make the HTTP call. In my example, the API is expecting Query String, so I’m passing the values in Queries as needed. It could be different in your case.
    I’m select GET method since we are trying to retrieve data by calling the API
    getSelected

    And then go on to write the rest of the request.
    sampleRequest
    Let’s say, if you’re required to pass headers to a POST request with Body, you can do that as well.

  3. And I’m capturing the response in a variable in Flow to further use it. I’ve chosen to store it in an Object type of variable.
    captureResponseEasy!

Making HTTP Request

Now, let’s test it. I made a sample request and I’ve received the response as below –
I’ll open my response part –
openResponse

Check this, in case you want to also secure the data your receive – Secure Input/Output in Power Automate Run History

And I’ve received the data successfully! Hope this gets you started in making HTTP calls.