#convert request body in api to boolean

1 messages · Page 1 of 1 (latest)

steel stormBOT
#

Hello! I'm AppsmithBot, here to assist you with your Appsmith queries.

To convert the string values from a Select widget to boolean in your request body, you can use JavaScript within the mustache syntax. Here's how you can modify your request body:

json
{
"campaignName": "test_payments",
"lamf": {?{ SelectWidget1.selectedOptionValue === "True" }?} ,
"pl": {?{ SelectWidget2.selectedOptionValue === "True" }?}
}

In this example, replace SelectWidget1 and SelectWidget2 with the actual names of your Select widgets. This code checks if the selected option value is "True" and converts it to a boolean true, otherwise it will be false.

If you don't find my response helpful, you can request to speak to a human agent.

gleaming glacier
#

this is the response body format i am passing . tell me how do i change to boolean :
{
"campaignName":{{Input15.text}},
"lamf": {{Select5.selectedOptionValue}},
"pl": {{Select6.selectedOptionValue}}
}

steel stormBOT
#

To convert the string values from the Select widgets to boolean in your response body, you can use the following format:

json
{
"campaignName": {?{ Input15.text }?} ,
"lamf": {?{ Select5.selectedOptionValue === "True" }?} ,
"pl": {?{ Select6.selectedOptionValue === "True" }?}
}

This will convert the string "True" to the boolean true and any other value to false. Make sure that the Select widgets (Select5 and Select6) are returning the string "True" when you want the boolean true.

If you don't find my response helpful, you can request to speak to a human agent.