Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Automate Query String: Read and Build URLs

· 6 min read · Home Automation

In this article
  1. What a query string is
  2. Read query parameters from an HTTP request
  3. Build a query string for an HTTP action
  4. Encoding, duplicates, and special cases
  5. Common problems and troubleshooting
  6. Security and practical design
  7. Frequently Asked Questions

In Power Automate, a query string is the part of a URL after the question mark that carries named values, such as ?status=open&page=2. To read a value from a trigger or action URL, use an expression such as triggerOutputs()?['queries']?['status'] when that trigger exposes query parameters; to create a query string safely, use the Compose action with uriComponent() to encode values and join them with ampersands.

What a query string is

A URL commonly contains a scheme, host, path, and optional query string. In https://example.com/orders?status=open&page=2, the query string is status=open&page=2. The question mark starts it; ampersands separate parameters, and an equals sign separates each parameter name from its value. A URL fragment beginning with # is different: fragments are handled by the browser and are not normally sent to a web server.

In Power Automate, query strings matter when a flow receives an HTTP request, calls a web service, or constructs a link. They are not the same thing as a flow’s trigger conditions or the parameters shown in an action’s fields. A connector may also represent query parameters as individual fields rather than requiring you to type a complete URL.

Read query parameters from an HTTP request

For a flow using the When an HTTP request is received trigger, query parameters are available in the trigger output when the request includes them. For example, a caller might send a request to the generated URL with ?ticket=8421&priority=high. In a later action, choose the relevant dynamic content if it is offered, or use an expression based on the trigger output:

  • For the ticket value: triggerOutputs()?['queries']?['ticket']
  • For the priority value: triggerOutputs()?['queries']?['priority']

Enter expressions through the expression editor in the action where the value is needed. The optional-navigation operators in these examples help avoid an expression error if an object or property is missing, but they do not supply a business-appropriate default. If a parameter is required, add a condition to check that it exists and is not empty before using it.

Query values are generally text. If a flow needs a number, date, or Boolean value, validate and convert it deliberately before using it in calculations or comparisons. Do not assume that a missing parameter, an empty value, and a value such as 0 mean the same thing.

Build a query string for an HTTP action

When calling an API, the HTTP action can use a complete URL, or you can add query parameters through the action’s query-related fields if available in the particular action or connector. Using separate fields is usually easier to read and reduces mistakes with URL encoding. If constructing the URL yourself, encode values that may contain spaces, ampersands, question marks, or other reserved characters.

For example, assume a Compose action has a search term in a variable named searchTerm, and the API endpoint is https://api.example.com/items. A Compose expression can encode the term before inserting it into a URL:

concat('https://api.example.com/items?q=', uriComponent(variables('searchTerm')))

If the search term is red & blue, encoding prevents the ampersand from being mistaken for the start of another parameter. To add more parameters, include an ampersand between pairs and encode each value independently. For example, a fixed page value can be appended as &page=2. Keep parameter names consistent with the API’s documentation; the service, not Power Automate, determines what names and values it accepts.

For dynamic values, avoid assembling a URL by inserting raw user input. Encoding helps preserve the intended URL structure, but it is not a substitute for validating inputs or controlling which host and endpoint a flow is allowed to call.

Encoding, duplicates, and special cases

URL encoding converts characters that would otherwise have special meaning or be unsafe in a URL into an encoded representation. Power Automate’s uriComponent() expression function is useful for encoding a component such as a parameter value. Encode the value, not the whole URL: encoding the complete URL would also encode its structural characters, including slashes and separators.

  • Spaces: Encode spaces in values rather than relying on a browser or service to interpret them consistently.
  • Ampersands: An unencoded ampersand inside a value can be read as a separator between parameters.
  • Repeated parameters: Some APIs accept repeated names, such as tag=a&tag=b; others expect a comma-separated value or another format. Follow the API specification.
  • Case: Parameter names may be case-sensitive to the receiving service. Use the spelling and capitalization it documents.
  • Empty values: ?name= is not necessarily equivalent to leaving out name. Check the receiving system’s behavior.

Encoding and decoding are separate operations. If a service returns an encoded value and the flow needs to display or process the original text, use the appropriate decoding expression supported in the flow environment, and confirm the exact output against the service’s format.

Common problems and troubleshooting

A frequent issue is looking for query parameters in the wrong part of the trigger output. Inspect the trigger’s run history, open its outputs, and check how the incoming request was represented. The exact shape can vary by trigger and connector, so expressions that work for an HTTP request trigger may not work unchanged for a different trigger.

  • The expression returns null: Confirm the request URL actually includes the parameter, and verify the parameter name and capitalization. Check whether the trigger exposes it under queries or another output structure.
  • The HTTP action returns an error: Review the final URL in the run history, including encoding, required parameters, authentication, and the API’s expected method and headers.
  • A value is cut off or split: Look for reserved characters, especially an unencoded ampersand or question mark in user-provided text.
  • A parameter works in a browser but not in a flow: Compare the exact request URL and method. A browser may add or normalize details that are absent from the flow’s request.
  • The trigger URL changes: Use the current URL provided by the flow trigger rather than relying on an old copied link, particularly after changing or recreating a flow.

Run a controlled test with a simple value first, then test spaces and punctuation. Use run history to inspect inputs and outputs, while taking care not to expose credentials, personal information, or sensitive query values in shared screenshots or logs.

Security and practical design

Query strings are convenient, but they are not a secure place for passwords, access tokens, or confidential data. URLs can be recorded in browser history, proxy or server logs, monitoring systems, and copied messages. Use an authentication method supported by the API, such as an appropriate authorization header or connector credential, rather than putting secrets in the URL.

Also treat incoming query values as untrusted input. Validate allowed values, check lengths and types, and avoid allowing a parameter to select an arbitrary destination URL. A flow that sends requests to destinations supplied by callers can create security and data-exposure risks. Apply the organization’s access controls and data policies, and limit who can invoke an HTTP-triggered flow.

Frequently Asked Questions

How do I get a query parameter in Power Automate?
For the HTTP request trigger, inspect its run outputs and use an expression such as triggerOutputs()?['queries']?['name'], replacing name with the parameter’s actual key. The output shape depends on the trigger.

How do I pass a query string in an HTTP action?
Use the action’s query parameter fields when available, or construct the URL with the documented parameter names. Encode dynamic values with uriComponent() so reserved characters do not change the URL’s structure.

Does Power Automate automatically decode query parameters?
Do not assume that every trigger or connector handles decoding identically. Inspect the actual run output, and use an appropriate decoding step only if the received value is still encoded.

Can a query string contain more than one parameter?
Yes. Put a question mark before the first parameter and separate later parameters with ampersands, for example ?status=open&page=2. Encode values that contain reserved characters.

Is it safe to put an API key in a query string?
Usually it is safer not to. Query strings can appear in logs and history. Prefer the API’s supported authentication mechanism and keep credentials in approved connection or secret-management facilities.