
Extract URL Query Paramters to Key:Value JSON in Power Automate (MS Flow)
2-3 minutes
Introduction
Power Automate only provides an expresion for extracting the query string from a url, it basicly just
splits on the '?'.
The flow shown in this blogpost extracts all query paramaters into a Key:Value JSON
object.
Example
Taking the following URL as input:
https://myapp.crm11.dynamics.com/main.aspx?appid=ca6fb934-ad35-49dc-a305-abc65d338b6f&forceUCI=1&pagetype=entityrecord&etn=jp_myentity&id=0634c174-b9d7-4ff9-bb59-c969505aefee
The flow returns the following JSON object.
{ "appid": "ca6fb934-ad35-49dc-a305-abc65d338b6f", "pagetype": "entityrecord", "etn": "jp_myentity", "id": "0634c174-b9d7-4ff9-bb59-c969505aefee" }
The Flow

Using the Flow
The flow depends on two input variables, a URL Input and a Object to store the output. You must create these first then using the input boxes below update the flow to use your variables.
To add this flow to your own click the copy button on the code code snippet.
Then go into your flow, click add step, go into 'My Clipboard' and press Ctrl+V, the flow should then be
shown for you to paste it.

{"id": "96196740-50ad-4fd9-83fa-22f52f8b7a2d","brandColor": "#8C3900","connectionReferences": {},"connectorDisplayName": "Control","icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYJPnptLTEgNXYJPGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger": false,"operationName": "Return_URL_query_params_as_a_JSON_K:V_Object","operationDefinition": {"type": "Scope","actions": {"JP:Get_Query_Param_String": {"type": "Compose","inputs": "@uriQuery(variables('JP:URL_Input'))","runAfter": {},"metadata": {"operationMetadataId": "dce0f493-0727-4af5-b951-426d43d6a921"}},"JP:Remove_the_leading_Question_Mark": {"type": "Expression","kind": "Substring","inputs": {"text": "@outputs('JP:Get_Query_Param_String')","startingPosition": 1},"runAfter": {"JP:Get_Query_Param_String": ["Succeeded"]},"metadata": {"operationMetadataId": "9bc8cdb3-420c-4d21-a3b7-a79dfd34572e"}},"JP:Split_on_Ampersand": {"type": "Compose","inputs": "@split(outputs('JP:Remove_the_leading_Question_Mark')?['body'], '&')","runAfter": {"JP:Remove_the_leading_Question_Mark": ["Succeeded"]},"metadata": {"operationMetadataId": "1aa1fe0b-27da-453e-ab65-bd776ecf2bd1"}},"JP:For_each_K:V_String": {"type": "Foreach","foreach": "@outputs('JP:Split_on_Ampersand')","actions": {"JP:Split_name_and_Value": {"type": "Compose","inputs": "@split(items('JP:For_each_K:V_String'), '=')","runAfter": {},"metadata": {"operationMetadataId": "76f1df63-598d-4d1a-9afe-f53910815346"}},"JP:ID": {"type": "Compose","inputs": "@first(outputs('JP:Split_name_and_Value'))","runAfter": {"JP:Split_name_and_Value": ["Succeeded"]},"metadata": {"operationMetadataId": "0cd2cf95-fad6-4f4c-aa5d-6f4aee691404"}},"JP:Value": {"type": "Compose","inputs": "@last(outputs('JP:Split_name_and_Value'))","runAfter": {"JP:ID": ["Succeeded"]},"metadata": {"operationMetadataId": "8ec6587b-07dc-41a4-9887-25f33c5de226"}},"JP:Write_KV_to_Output": {"type": "SetVariable","inputs": {"name": "JP:URL_Params","value": "@outputs('JP:Temp_Output')"},"runAfter": {"JP:Temp_Output": ["Succeeded"]},"metadata": {"operationMetadataId": "be06a384-e591-45da-9648-13d7eb415b45"}},"JP:Temp_Output": {"type": "Compose","inputs": "@union(addProperty(variables('JP:URL_Params'), outputs('JP:ID'), outputs('JP:Value')), variables('JP:URL_Params'))","runAfter": {"JP:Value": ["Succeeded"]},"metadata": {"operationMetadataId": "9322affc-f966-470d-9c2e-993e3385d7ed"}}},"runAfter": {"JP:Split_on_Ampersand": ["Succeeded"]},"runtimeConfiguration": {"concurrency": {"repetitions": 1}},"metadata": {"operationMetadataId": "8f7afbb7-6321-4814-86ca-1ed388dadcb0"}}},"runAfter": {"JP:K:V_URL_Params_Output": ["Succeeded"]},"metadata": {"operationMetadataId": "90cddcb4-7429-4a63-8dd2-5ef3cdd9d545"}}}