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.
- In your connectors, select the below connector ‘When an HTTP request is received‘
- 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‘.
- Now, enter your sample data and click Done.
- Schema will be generated automatically.
- Now, save your Flow so that a URL could be generated.
- Also, remember to select what type of Request to accept. It’s under the Show advanced options
- 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.
- Supported verbs in the HTTP Request trigger are GET, PUT, POST, PATCH, DELETE –
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.
- Now, search for Response (or rather Request) in the Connectors list and you’ll be able to choose the Response action.
- 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)
- 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.
- 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)
- Now, I am sending the data in the body in the following way
- Now, let’s say I submit the request using Postman.
A record will be created in my D365 (Common Data Service)
- And the Token that the record generated will be returned as response back to Postman
With the status of 200 OK
- 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
- Make HTTP request from Flow in Power Automate
- Setting Retry Policy for an HTTP request in a Flow | Power Automate
- Terminate a Flow with Failed/Cancelled status | Power Automate
- Adaptive Cards for Teams to collect data from users using Power Automate | SharePoint Lists
- BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
- ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
- Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
- Pause a Flow using Delay and Delay Until | Power Automate
- Get Count of records retrieved in CDS connector in a Flow | Power Automate
- Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
- Switch-Case in a Flow | Power Automate
- Using Parse JSON to read individual List Records in Flow|Power Automate
Hope this was useful! 🙂