Ran into an
interesting issue challenge with Logic Apps.
My Logic App sometimes takes a query parameter called
I use the value of
planIdto determine whether I should Insert or Update a record in a database.
planId is not provided the statement
triggerBody()['queries]['planId'] generates an exception.
This was very frustrating to figure out how to get around this.
Thankfully, I stumbled across an article at https://social.msdn.microsoft.com/Forums/en-US/6ef38571-9fac-482a-81c7-50289d14e959/how-to-access-query-parameter-in-logic-app which pointed me in the direction of the fix.
It was pretty simple.
I just needed to add a couple of
? to the expression, so my original expression,
triggerBody()['queries]['planId'], should be changed to
? are the key.
This will allow the parameter string and parameter to be missing and the code to not generate an exception.
Hope that helps!