Team,
I am trying to mock my request using mock server but the response not getting as expected (I observed that in postman web view there no prescript found)
I have requests like below
{“username”:“value1”,
“addr” : {“skey1”:“svalue”
},
“mobileNumber”:“value2”
}
like this i have requests …
response should be like this :
{“username”:“value1”,
“addr”:{“skey1”:“svalue”}
}
Ways i have tried using preScript
var reqBody= pm.request.body.raw
console.log(reqBody)
//console.log(req)
var json_verify = function(reqBody){ try { JSON.parse(reqBody); return true; } catch (e) { return false; }}
if(json_verify){
var val = JSON.parse(pm.request.body.raw)
var bol = true
for(var key in val)
{
postman.setEnvironmentVaribale(key,val[key])
...
}
}
and using this key in response body. but
please help me any way on achieving this
let me know if you need any thing