0
votes

I have a GET request from where I extract the variable ${SAMLRequest} (Regular Expression Extractor).

Value of ${SAMLRequest} is as follows: VhJUVNXeHBPRjNMdnNvNHpTUT09PC9YNTA5Q2VydGlmaWNhdGU+PC9YNTA5RGF0YT48L0tleUluZm8+PC9TaWduYXR1cmU+PHNhbWxwOk5hbWVJRFBvbGljeSBBbGxvd0NyZWF0ZT0idHJ1ZSIgLz48L3NhbWxwOkF1dGhuUmVxdWVzdD4=

Next I have a POST request, and I want to post the variable ${SAMLRequest} with some changes.

Instead of the sign + I want to have %2B and instead of =, I want to have %3D.

Do you know how I can change a variable in JMeter?

2

2 Answers

0
votes

Use beanshell preprocessor1 in your post sampler

0
votes

The easiest way is to check "Encode?" box for SAMLRequest parameter in your POST request body

The harder way is using __urlencode() JMeter Function.

The hardest way is BeanShell Pre Processor as okwap suggests. However it'll give you the full control.

Relevant Beahshell code will look like:

import java.net.URLEncoder;

String source = vars.get("SAMLRequest");
String encoded = URLEncoder.encode(source);
vars.put("SAMLRequest", encoded);