jmeter http request decode %2F in HTTPSampler.path which i want to keep

0

I'm new to jmeter. Jmeter version I used is 5.1.1

And i want to use it to test my restful api service.
My api like: DELETE /cpro/v2/alertfiles/{filename}
Filename here will be /etc/config/testfile1.

The server could parse the filename if the curl command like:
curl -v -X DELETE http://restapisrv:8888/cpro/v2/alertfiles/%2Fetc%2Fconfig%2Ftestfile1?configmapName=zt3-cpro-server

I created a http request. but the url sent by jmeter has decoded %2F to '/'. so the request looks like DELETE /cpro/v2/alertfiles/etc/config/testfile1 which made the server return 404 since no such entry could be found. <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="delete alert file test1" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> <collectionProp name="Arguments.arguments"/> </elementProp> <stringProp name="HTTPSampler.domain">restapisrv</stringProp> <stringProp name="HTTPSampler.port">8888</stringProp> <stringProp name="HTTPSampler.protocol">http</stringProp> <stringProp name="HTTPSampler.contentEncoding">utf-8</stringProp> <stringProp name="HTTPSampler.path">/cpro/v2/alertfiles/%2Fetc%2Fconfig%2Ftestfile1?configmapName=zt3-cpro-server&amp;namespace=default</stringProp> <stringProp name="HTTPSampler.method">DELETE</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy>

I tried to use __urlencode(/etc/config/testfile1) in path, but it's the same result. I don't know how should i set the value of HTTPSmapler.path to keep the %2F. Any idea about that? Thanks for your help.

user1654115

Posted 2019-06-06T06:55:16.090

Reputation: 1

Answers

0

I use the plugin http raw request to resolve the issue. it's a workaround. The config like:

 <kg.apc.jmeter.samplers.HTTPRawSampler guiclass="kg.apc.jmeter.samplers.HTTPRawSamplerGui" testclass="kg.apc.jmeter.samplers.HTTPRawSampler" testname="delete alert file test2 - HTTP Raw Request" enabled="true">
          <stringProp name="hostname">zt1-cpro-restapisrv-restserver</stringProp>
          <stringProp name="port">8888</stringProp>
          <boolProp name="keepalive">false</boolProp>
          <stringProp name="timeout">0</stringProp>
          <stringProp name="data">DELETE /cpro/v2/alertfiles/%2Fetc%2Fconfig%2Ftestfile2?configmapName=zt3-cpro-server&amp;namespace=default   HTTP/1.1&#xd;
User-Agent: curl/7.29.0&#xd;
Host: zt1-cpro-restapisrv-restserver:8888&#xd;
Accept: */*&#xd;
Connection: close&#xd;
&#xd;
</stringProp>
          <stringProp name="fileName"></stringProp>
          <boolProp name="parse">true</boolProp>
        </kg.apc.jmeter.samplers.HTTPRawSampler>

jmeter GUI

user1654115

Posted 2019-06-06T06:55:16.090

Reputation: 1

I think you need to add some illustrations,, to show the exact way to fix the issue! – Rajesh S – 2019-06-10T08:25:38.497