How to get Sampler Body data from beanshell Pre-Processor - JMeter

GKalya

I have Http Sampler body as follows, {"Uname":"admin","Signature":"${Sign}","LoginTime":"${LogTime}","Action":"Do_Action"}

I have to get the value of "Action" from the above body, and that value nned to be sent to Pre-processor which will be useful to do further action.

Help me out of this...!!

Thanks!

Dmitri T

I would recommend switching to JSR223 PreProcessor and Groovy language as:

  1. Groovy has built-in JSON support
  2. Groovy performs much better than Beanshell

Example Groovy code to extract "Action" from the request body and store it into ${action} JMeter Variable will look like:

def body = new groovy.json.JsonSlurper().parseText(sampler.getArguments().getArgument(0).getValue())
vars.put('action', body.Action)

See Groovy is the New Black article for more details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive