dhairya
dhairya

Reputation: 445

How to pass the dynamic value in Body data in the Post Request using jmeter

I recorded the .JMX script in Jmeter and one of the request is as below

POST http://www.hello.com/auth/nqa/md/login

Body data: {"domainId":"nqa","code":"12345skdkdk"}

I would like to send the "code" field dynamically and for that I added the regular expressing extractor as below enter image description here enter image description here

enter image description here

When i re run the script , the code value is not replaced with the dynamic value.

Not sure what part i am missing in the regular expression extractor or in the Body data field

Upvotes: 4

Views: 10874

Answers (2)

moien ghorbani
moien ghorbani

Reputation: 127

  • List item

you should do three-step of below

  1. go to the random variable according below picture enter image description here

  2. Define random variable name . in this case we set variable name to code1 and set min & max value to this

enter image description here

  1. Use ${code1} variable to your data section

enter image description here

Upvotes: 10

Dmitri T
Dmitri T

Reputation: 168002

  1. First of all, you cannot extract the value from the request body using the Regular Expression Extractor, normally you should extract the dynamic values from the previous response so inspect the whole flow using View Results Tree listener and look for your "code" value there
  2. Your regular expression extractor in its current configuration will return random value in the parentheses so it could be domainId, nqa, code or 12345skdkdk. Going forward if you need to get some dynamic data from JSON go for JSON Extractor or JSON JMESPath Extractor

Upvotes: 3

Related Questions