12
votes

I'm trying to pass an extra query parameter to Azure logic app so that I can process below data in the Logic App workflow

For Example https://logicURL?SelectedData="%7BsiteURL%3AXYZ.sharepoint.com%2Fsites%2FXYZDev%7D" (encoded string)

In HTTP action I am trying to handle above passed data with below JSON schema

{
    "kind": "Http",
    "inputs": {
        "schema": {
            "properties": {
                "selectedData": {
                    "type": "string"
                }
            },
            "type": "object"
        }
    } }

I am not getting selectedData value. I need to use decodecomponentURI and then use the JSON value.

Azure logic app schema

Find the error here

Azure logic app run time error

3
In simple words, how do I process parameter inside Azure Logic App which came through URLuser1891797

3 Answers

14
votes

First, you need to add your query param to the existing ones, e.g.

https://xyz.logic.azure.com:443/workflows/id/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=code&SelectedData="%7BsiteURL%3AXYZ.sharepoint.com%2Fsites%2FXYZDev%7D"

https://xyz.logic.azure.com:443/workflows/id/triggers/manual/paths/invoke
  ?api-version=2016-10-01
  &sp=%2Ftriggers%2Fmanual%2Frun
  &sv=1.0
  &sig=code
  &SelectedData="%7BsiteURL%3AXYZ.sharepoint.com%2Fsites%2FXYZDev%7D"

Then, you should be able to get them in your Logic App using

@triggerOutputs()['queries']['SelectedData']

As you can see, there is no need to add a schema to the Http Trigger to get a query parameter

4
votes

Context

  • MSFT Azure Logicapp
  • MSFT Logicapp workflow definition language
  • Live version as of 2020-06-25 04:56:31

Problem

  • Logicapp developer wants to obtain the value of a URL query parameter passed in via HTTP GET

Solution

  • The solution to this use-case is already provided elsewhere in this StackOverflow thread
  • This addon answer, however, refactors the previous solution
    • it addresses constructing expressions in MSFT Workflow definition language (the JSON-based source code you see when viewing a logicapp in "code" view)

Details

  • This URL extends the original question and another answer in this SO Thread
  • Here we expect FirstName LastName and FaveColor properties
    https://xyz.logic.azure.com:443/workflows/id/triggers/manual/paths/invoke
      ?api-version=2016-10-01
      &sp=%2Ftriggers%2Fmanual%2Frun
      &sv=1.0
      &sig=code
      &FirstName=Huomer
      &LastName=Huimpson
      &FaveColor=     
  • Standard init: The following is sufficient to capture the desired name-value pairs
triggerOutputs()['queries']['FirstName']
triggerOutputs()['queries']['LastName']
triggerOutputs()['queries']['FaveColor']
  • Error-trap init: The following is sufficient to capture the desired name-value pairs without throwing an error if any desired name-value pair is missing (error-free capture)
triggerOutputs()['queries']?['FirstName']
triggerOutputs()['queries']?['LastName']
triggerOutputs()['queries']?['FaveColor']
  • Error-trap init with defaults: The following is sufficient to error-trap init the desired name-value pairs, as well as provide a default value for any missing values
coalesce(triggerOutputs()['queries']?['FirstName']  , 'Puomer'  )
coalesce(triggerOutputs()['queries']?['LastName']   , 'Puimpson' )
coalesce(triggerOutputs()['queries']?['FaveColor']  , 'Purple' )

Solution refactored

  • Consequently, the original solution can be refactored as follows
## BEFORE
@triggerOutputs()['queries']['SelectedData']

## AFTER
@{coalesce(triggerOutputs()['queries']?['SelectedData'] , '__blank__')}
  • This approach does what the typical use-case calls for, which is:
    • get the value if it exists,
    • otherwise provide a default value, and
    • don't crash the entire logicapp if the parameter was completely omitted
    • the @{} syntax can be used if you are editing workflow definition language directly, but not if you are entering it in the "expression dialog box"

See also

0
votes

I am sending query String as:

https://prod-17.westindia.logic.azure.com:443/workflows/f3b63b086e61420e8d76b7478f4b3e39/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=nESqZWY2NyAKKhCkaM0VnfenHuTqi1NSBjJdl9M5jNA&UserName=SecretName&Password=Nikita@123

I want to extract UserName in logic app. For that I have used Compose connector and use following statement in expression.

coalesce(triggerOutputs()['queries']?['UserName'] , 'blank')

I have tried this to:: triggerOutputs()['queries']?['UserName']

But I am getting one single blank space appended in front of UserName in output. Due to which, my condition is becoming false even if UserName is correct.

How to remove this extra space which is unnecessary appending to front. enter image description here

HTTP Connector Output as : enter image description here