Dynamically Set Custom Connector URL using Policy Templates
  • 22 Jan 2021
  • 1 Minute To Read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Dynamically Set Custom Connector URL using Policy Templates

  • Print
  • Comments
  • Share
  • Dark
    Light

#ServerlessTips - Power Automate
Author: Kent Weare Integration MVP

Custom connectors allow you to connect to systems that do not have a readily available connector for Power Automate or Power Apps. As part of the custom connector wizard, we can establish specific parameters such as the endpoint Host URL but what happens if we want to change this value at runtime? The answer is a feature in the custom connector wizard called Policy Templates.

Policy Templates can be access from the Definition tab and there are several Templates that are available to us including:

• Set host URL
• Set HTTP header
• Set query string parameter
1-Templates

The benefit of using this approach is that we can leverage runtime values for these properties that may not be available to us at design time.

Let’s take a look at an example of how we can dynamically set our URL at runtime by selecting the Set host URL template. Once we select this template, we need to provide our Url Template which will instruct the connector on where to retrieve this value to replace the URL that we specified at design time when creating this connector. In this scenario, we will use a Query Parameter called new_url. Whatever value is provided in this query parameter will be used to connect to that host.
2-URLTemplate

Now it is important to note that this new_url query parameter needs to be part of our operation definition. For example, within this particular operation this query parameter has been defined in our Request.
3-NewURL

Once we save and publish this connector, we can use it within a flow. In our scenario, we have a property within our custom connector action that we can use to provide our new URL that can be configured in our flow or can be set through dynamic content. This value will be substituted at runtime and override the Host URL that we defined at design time.
4-flow

Conclusion

Custom connectors provide an extensibility experience for Power Automate and Power Apps. When there is a need to dynamically set values like URLs, query parameters or headers, we can use Policy Templates within custom connectors to drive this behavior.

Was This Article Helpful?