Hi, I just want to have an option to apply JSON validation in application/x-www-form-urlencoded requests. Thanks.
Solved! Go to Solution.
Hi Dino,
I already find the answer about this question. Thanks for attending on our questions.
Here is what I found and it works. Hope it helps others also. It applies also on query parameters. Just replace "request.formstring" with "request.querystring".
var formRequest = context.getVariable("request.formstring").split("&");
formRequest.forEach(function(keyValuePair) {
var nameAndValue = nameValuePair.split('=');
jsonOutput += '"' + nameAndValue[0] + '"' + ':' + '"' + nameAndValue[1] + '"' + ',';
});
Output = '{' + Output.substr(0, Output.length -1) + '}';
context.setVariable('request.content', Output);