Today while my team and I were trying to do a small Logic App proof-of-concept using a Request – When a HTTP request is received trigger – something quite simple and basic – with a simple JSON payload like:
{
"Data":[
{
"LogicAppName":"",
"ResourceGroupName":"",
"SubscriptionID":""
}
]
}
We were always getting the following error when we were trying to trigger the Logic App using Postman:
InvalidTemplate. Unable to process template language expressions for action ‘For_each’ at line ‘0’ and column ‘0’: ‘The template language expression ‘triggerBody()?[‘Data’]’ cannot be evaluated because property ‘Data’ cannot be selected. Property selection is not supported on values of type ‘String’. Please see https://aka.ms/logicexpressions for usage details.’.
To be honest, I was getting annoyed because this a simple stuff that I have done thousands of times!
Cause
Unfortunately, I cannot use the common excuse: “sorry, it is Friday!” because today is Tuesday :). But I can always say that most of the time the error resides between the chair and the keyboard! 🙂
You may pay more attention to the Logic App designer when you define a JSON Schema in your When a HTTP request is received trigger. It will warn you not to forget to include a Content-Type header set to application/json in your request!
If you do not provide the Content-Type header, it will assume that is plain text, and it will not parse the JSON and render all the properties, so it will not going to be tokenized, and there you will get this or similar errors.
Solution
The solution is quite simple, on the Postman request add a Content-Type header and set it to application/json.
If you try again… problem is solved!
Hope you find this useful!
My youngest son (almost 5 years old) is a big Star Wars fan, and when I’m trying to write something, and he arrives home and want to play with me, I always say to him: Let the father finish work to earn some money so we can buy more toys… now I promise him that all contributions from my blog are going to be used for buying Star Wars Legos!
So, if you liked the content or found it useful and want to help me write more content, you can buy (or help buy) my son a Star Wars Lego! 🙂