Can anyone help me on this case, i want to put value of variable "pass" to String "formValue", but cannot load the right body for http post request using Jmeter: steps, ThreadGroup with HTTP Request has ${formValue} on body tab, add beanShell PreProcessor with script bellow:
String pass = "123456";
String formValue = "{\"userName\": \"admin\",\"password\":vars.get("pass")}";
vars.put("formValue",formValue);
thanks!
If I correctly getting the idea your code should be amended as follows:
String pass = "123456";
vars.put("pass", pass);
String formValue = "{\"userName\": \"admin\",\"password\":\"" + vars.get("pass") + "\"}";
vars.put("formValue", formValue);
See How to Use BeanShell: JMeter's Favorite Built-in Component article for more Beanshell and JMeter related tips and tricks.