{tocify} $title={Table of Contents}
So, provided the output of Delete_API to string function, which later was provided as input to replace() function.
Issue
Was working on a requirement to handle quotes(") coming in the value of a property/field, for that made use of replace() function to add escape character.
Read following for detail -- How to handle double quotes in JSON value
However, while doing so - received following error at runtime
InvalidTemplate. Unable to process template language expressions in action 'Log_Success' inputs at line '0' and column '0': 'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#replace for usage details.'.
Why it happened
replace() is a part of string functions available in Logic app, which can be used in expressions.
It basically replaces a substring within the specified string, and returns the updated string.
I was applying replace function on the output of an action which was calling an http endpoint
replace(replace(replace(body('Delete_API'),'}',''),'{',''),'"','\"')
So, there was error due to the type of Delete_API (http endpoint) i.e. the output of Delete_API was a Object and not string.
What to do
To make replace function complain free, it should be provided with a string as input.
So how to convert the object to String?
We can make use of string() function.
string() is part of conversion function available in Logic app and can be used in expression and it returns the string version for an input value.
replace(replace(replace(string(body('Delete_API')),'}',''),'{',''),'"','\"')
If you have questions or suggestions, feel free to do in comments section below !!!
Do share if you find this helpful .......
Knowledge Sharing is Caring !!!!!!
Learn More about some more Logic App errors
- The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used
- Selected file must be between 1 and 2097152 bytes
- SplitOn property doesn't validate expression at design time
- The workflow with 'Response' action type should not have triggers with 'splitOn' property
- The template language function 'xpath' expects its first parameter to be an XML object
- The template language expression 'xxx' cannot be evaluated because property 'xxx' doesn't exist. Property selection is not supported on content of type 'application/xml'
Tags:
Azure Logic App Error