Jmeter phrasing the value

Viewed 33

I need to encrypt the below value: encryption api is : url/api/enc/

{"login_user_id":"salem","Platform":"Android","AppVersion":"v2.1.17-uat 1.14.17","AppVersionCode":88,"BandWidthSpeed":"64","ApproxBandWidthSpeed":"10+ Mbps","device_id":"136e35b88a09cd16","BatteryStatus":"84","language":"en","Country":"","DeviceOffset":"19800","DeviceDateTime":"2022-09-14 11:00:40","UtcDateTime":"2022-09-14 05:30:40","NetworkType":"TYPE_MOBILE","NetworkSubType":"LTE","ip_address":"192.168.43.1","DeviceModel":"M2006C3MI","DeviceManufacture":"Xiaomi","DeviceOsVersion":"29","IMEI":"","analytical_url_status":"SUCCESS","analytical_url":"api\/apply_weekoff","analytical_time":"1703"}

I am passing all the parameters in the path by encoding such as { - %7B, } -%7D and " with % 22

But i am getting error with - "analytical_url":"api\/apply_weekoff" this part / i have tried with \-%5C & / with %2F but it is not working Is there any suggestion to convert the values of \/

1 Answers

It's not clear what you're trying to achieve.

You can use __urlencode() function like

${__urlencode("analytical_url":"api/apply_weekoff")}

and you will get

%22analytical_url%22%3A%22api%2Fapply_weekoff%22

enter image description here

If you want to change the value in the response from apiaply_weekoff to api\/apply_weekoff you can use JSR223 PostProcessor and Groovy language to replace it on the fly and substitute the response

def response = new groovy.json.JsonSlurper().parse(prev.getResponseData())

response.analytical_url = 'api\\/apply_weekoff'

prev.setResponseData(new groovy.json.JsonBuilder(response).toPrettyString(),'UTF-8')
Related