cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Don't Auto-Capitalize Boolean Value

Hello,

 

I'm building a JSON object for an HTTP Response action, but I'm getting an error that my JSON is malformed. When examining the body, I see that this is because my Boolean types have their first letter capitalized. According to the JSON spec, Booleans must be lowercase, so that's definitely the issue.

 

However, I already know that true/false are acceptable and True/False are not, and have been setting & passing lowercase Booleans without issue. The difference this time is that I'm working with the Booleans in the context of a string variable.

 

Capitalization.png

 

Flow is formatting my Boolean type as some kind of non-standard string, and nothing that I've tried has been able to fix it. I expected to be able to simply pass the variable in without issue:

 

Expected Solution.png

 

But as we've seen, that doesn't work. I also tried pulling the changed variable into a compose action before using it in the Append to string variable action, but the Boolean is lowercase in the Compose and the Compose becomes uppercase when it's used in the Append action.

 

According to a post on the Flow help forum, this logic is by design. I can't understand why such behavior would be desired, but there must be a way to circumvent it, right? Is there a method for returning a raw/unformatted variable? I have tried:

 

 

 

 

bool(tolower(string(body('HTTP:_Field_Changed')?['changed'])))

 

 

 

 

 However, that didn't seem to make any difference. I'm lead to believe that this behavior is part of the Append to string variable action, but I can't skip that step, so any other thoughts or help are appreciated!

 

I can't change the type to string or int because the call that I'm replying to expects a (well-formed) JSON Boolean, and I would like to avoid a bunch of casting because I have several similar actions inside a loop, so all of those extra resources would equate to extra time.

 

Thanks for your help!

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

If you are concatenating strings, maybe you can try using concat () instead of Append to string variables.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MatejSamler
Frequent Visitor

For anyone having this issue: 

Sadly, this is still a thing. The only real way to print valid json is to do an unneccesary check like this: 
if(triggerOutputs()?['body/somebool'],'true','false')


Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (3,014)