Sometimes you need to work with URI (uniform resource identifiers) in Power Automate. URIs point at something, like websites, files, and so forth. You should be familiar with their most common format, the URL (uniform resource locator):

https://barretblake.dev/blog/?hello=23

The first portion (“https”) identifies the protocol or scheme. The second portion (“barretblake.dev”) points to the domain, or server, where the target is located. And the next portion (“blog”) points to the specific resource on that target server. A URI can also include optional parameters to be passed in. In the example above we’re passing in the parameter “hello” and a value for it of “23”.

There are quite a few different schemes, including the ability for apps to define custom schemes that will allow those apps to respond to URIs themselves.

In Power Automate, there are times when you need to pick apart the various pieces of a URI for use within a flow. Thankfully, the system provides a number of functions to make picking apart a URI and getting its values quite simple.

uriScheme

The uriScheme function will pull out the scheme, or protocol, from the URI. The pattern is simple:

uriScheme('<URI>')

In all of these functions, the URI parameter is a string value and can be passed in hard coded, as a variable, or as the output of a previous action or trigger.

Examples:

uriScheme('https://barretblake.dev')  // returns 'https'
uriScheme('telnet://192.168.0.1')  // returns 'telnet'
uriScheme('file:///c:/temp/test.txt')  // returns 'file'

uriHost

The uriHost function returns the host value from the URI. In most cases, this will be the server, or domain name, of the target.

uriHost('<URI>')

Examples:

uriHost('https://barretblake.dev')  // returns 'barretblake.dev'
uriHost('telnet://192.168.0.1')  // returns '192.168.0.1'
uriHost('file:///c:/temp/test.txt')  // returns 'c:'

uriPort

For URIs where the port to be connected to is not the default port number, then it is added to the host section of the URI. The uriPort function will pull out that value. In the cases where the URI passed in does not have a port, the function will return the default port for that scheme, if there is one.

uriPort('<URI>')

Examples:

uriPort('https://localhost:8080/index.html')  // returns '8080'
uriPort('https://barretblake.dev')  // returns '443'

uriPath

The uriPath function returns the path segment, which is everything after the host and port and before the query portion. This is the segment that points at the actual resource to be accessed.

uriPath('<URI>')

Examples:

uriPath('https://barretblake.dev/blog')  // returns '/blog'
uriPath('file:///c:/temp/test.txt')  // returns '/temp/text.txt')

uriQuery

This function will return anything that’s part of the query, if there is one (i.e. anything after the “?” indicator).

uriQuery('<URI>')

Example:

uriQuery('https://barretblake.dev/blog?name=barret')  // returns '?name=barret'

uriPathAndQuery

While uriPath and uriQuery return just the path or query segments respectively, the uriPathAndQuery function returns both together.

uriPathAndQuery('<URI>')

Example:

uriPathAndQuery('https://barretblake.dev/blog?name=barret')  // returns '/blog?name=barret'

Conclusion

There are a lot of situations where you need to pick out one or more pieces of a URI. This block of functions will help you do just that.

Next week, we’ll delve into the manipulation functions which will let us alter and work with JSON and XML data.