Dynamically Retrieve the HTTP URL of an HTTP-Triggered Power Automate Flow

 


How to Dynamically Retrieve the HTTP URL of an HTTP-Triggered Power Automate Flow

If you’ve ever needed to dynamically retrieve the HTTP URL of a Power Automate flow with an HTTP trigger, this step-by-step guide will help you create a solution to achieve that. We’ll use a flow that accepts two input parameters (Environment ID and Flow ID), performs an HTTP request using pre-authorized credentials, and generates a response containing the URL.


Step 1: Create a New Solution

  1. Navigate to the Solutions section in Power Apps or Power Automate.
  2. Click New Solution and provide:
    • Name: "GetHTTPFlowURL"
    • Publisher: Select an existing publisher or create a new one.
  3. Save and open the solution.




Step 2: Create an Instant Flow

  1. Inside the solution, click New > Automation > Cloud Flow > Instant.


  2. Name the flow (e.g., "GetHTTPFlowURL") and select the Manually trigger a flow option.


  3. Add the following input parameters:
    • Environment ID: Text input.
    • Flow ID: Text input.



Step 3: Add HTTP Request Action

  1. Add a new action and search for HTTP with Azure in connectors. Select the preauthorized one.



  2. Configure connection reference as follows:
    • Base URIhttps://asia.api.flow.microsoft.com
    • Resource URIhttps://service.flow.microsoft.com

      Note: The region of Base URI will be specific to your region. i.e. asia, unitedkingdom or emea.


  3. Select Sign In and configure the action as follows:
    • Method: POST
    • URL:

https://asia.api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/@{triggerBody()['text']}/flows/@{triggerBody()['text_1']}/triggers/manual/listCallbackUrl?api-version=2016-11-01

    • Headers:

Accept: application/json


Note: The region of Base URI will be specific to your region. i.e. asia, unitedkingdom or emea.

Step 4: Add a Response Action

  1. Add a Response action after the HTTP request.
  2. Set the Status Code to 200.
  3. In the Body field, pass the body of the HTTP request:

@body('Invoke_an_HTTP_request')

  1. Use the output schema from the HTTP response to define the structure:
{
    "type": "object",
    "properties": {
        "response": {
            "type": "object",
            "properties": {
                "value": {
                    "type": "string"
                },
                "method": {
                    "type": "string"
                },
                "basePath": {
                    "type": "string"
                },
                "queries": {
                    "type": "object",
                    "properties": {
                        "api-version": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "httpStatusCode": {
            "type": "string"
        }
    }
}




Step 5: Test the Flow

  1. Save and Test the flow.
  2. Provide sample inputs for Environment ID and Flow ID.


  3. Verify that the HTTP request retrieves the correct URL for the HTTP trigger in the specified environment and flow.



Feel free to download the sample solution from my GitHub:

Step 6: Deploy and Use the Flow

  1. Add this flow to any automation scenario where you need to dynamically retrieve the HTTP URL.
  2. Ensure proper permissions for users interacting with the flow.

Conclusion

This solution streamlines the retrieval of HTTP URLs for HTTP-triggered flows, making it ideal for dynamic scenarios in complex environments. By leveraging Power Automate's capabilities, you can automate this process and integrate it seamlessly into your systems.

 

Comments

  1. I am receiving this error while creating this flow:

    {
    "error": {
    "code": "ListCallbackUrlOperationBlocked",
    "message": "The list callback url operation is blocked for triggers of type 'Request'."
    }
    }

    ReplyDelete

Post a Comment