karthik
karthik

Reputation: 31

jmeter http request, beanshell preprocessor output is displayed in square brackets

I am extracting a URL located in the sub sample request, using the jmeter regex. the URL is escaped eg: has %3D, %3F. To unescape these I used beanshell preprocessor and replaced all these special characters. But when I use this variable(url) in the HTTP request its getting parsed with square brackets

code snip of bean shell preprocessor :

url = vars.get("escapedUri"); //get escaped url from the regular expression
url = url.replaceAll("%3A", ":");  //replace special characters with :,/,=,?
url = url.replaceAll("%2F", "/");
url = url.replaceAll("%3F", "?");
url = url.replaceAll("%3D", "=");
log.info ("escaped uri chng : " + url);
vars.put("URL", url);

The URL when printed in log file is displayed properly :

xyz?ID=Login-ID&goto=http://uri/?ReqID=abcdefghijklmnop

When I try to use this URL variable in HTTP request sampler is parsing it as follows.

https://[xyz?ID=Login-ID&goto=http://uri/?ReqID=abcdefghijklmnop]

jmeter test plan -> 
thread -> 
http request
  -> regex
http request
  -> bean shell preprocessor

can you please help me resolving this issue

Upvotes: 1

Views: 1112

Answers (1)

Dmitri T
Dmitri T

Reputation: 168072

My expectation is that you're using that ${URL} variable in the "Server Name or IP" field when it needs to go to "Path"

URL in PATH

Also I'm pretty sure that it's possible to get more "clean" URL from the Regular Expression Extractor. Check the following material:

Upvotes: 1

Related Questions