I’m facing an issue while passing boolean values within a JSON template in Azure Data Factory (ADF). My scenario involves transmitting a boolean variable from ADF to a Logic App. However, I encounter errors depending on how I handle the boolean value.
Here’s the problem: if I pass the boolean directly as a boolean (without quotation marks), I encounter parsing errors in ADF. On the other hand, if I pass the boolean as a string (with quotation marks), my receiving Logic App throws an error because it expects a boolean and can’t interpret the string representation.
Here’s a simplified version of what I’ve tried:
{
"emailSubject": "@{variables('jsonEmailLogicAppBody')[0]}",
"emailContent": "@{variables('jsonEmailLogicAppBody')[1]}",
"onDevelop": @{pipeline().parameters.sendMailAsTest} //Results in True
}
Result in the next error:
{
"error": {
"code": "InvalidRequestContent",
"message": "The request content is not valid and could not be deserialized: 'Unexpected character encountered while parsing value: T. Path 'onDevelop', line 4, position 17.'."
}
}
And when passing as a string:
{
"emailSubject": "@{variables('jsonEmailLogicAppBody')[0]}",
"emailContent": "@{variables('jsonEmailLogicAppBody')[1]}",
"onDevelop": "@{pipeline().parameters.sendMailAsTest}" // Parse as "True" but results in Logic App error
}
I’d prefer to avoid passing the boolean as a string to ensure data integrity, but if there’s no other option, I’m open to converting it back within the Logic App.
I’ve attempted to use the json() function within ADF to parse the boolean value, but I’m encountering difficulties getting it to work properly.
Any insights or suggestions on how to handle boolean values in this scenario would be greatly appreciated. Thank you!
2
Answers
Try using the
bool
function:The ADF expression is sending the boolean value as
True
but in JSON onlytrue
is accepted. Thats why I have replaced by converting it into string. Don’t add any quotes around it, so that it stays as booleantrue
in JSON.Use the below expression in Web activity body:
These are the values I have given for the parameters.
Logic app Output after pipeline run: