4
votes

I am new to JMeter and still in learning phase.

I am making a rest call in JMeter. The response data that i receive, i want to use it as it is in following rest call. Sample of response data that i receive is:

{  
   "token":"ab062ad1-0585-4b41-b491-1bd4f6de57da",
   "refreshToken":"5444b837-7f18-4570-a84b-80dac80b393c",
   "expiresBy":"Sat May 02 14:49:06 EDT 2015",
   "mcomroles":[  
      "Super BA Admin",
      "WorkgroupSuperBAUser"
   ],
   "bcomroles":[  
      "Super BA Admin",
      "WorkgroupSuperBAUser"
   ]
}

For this i added a Regular Expression Extractor but i do not know what regular expression to give.

Please suggest. Thanks.

2
value of JSONResponse is not getting replaced with its value - silver_noodles
GET 11.120.111.148:8081/token/validate [no cookies] Request Headers: Connection: keep-alive Accept: application/json accessToken: ${JSONResponse} Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Accept-Language: null User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0 Accept-Encoding: gzip, deflate Pragma: no-cache Host: 11.120.181.148:8081 - silver_noodles
Can you post your Jmeter test? - vins

2 Answers

9
votes

If you want to use response as it is , add a beanshell-post processor instead of Regular Expression Extractor.

vars.put("JSONResponse", prev.getResponseDataAsString());

Now you access it using below statement in the next request.

${JSONResponse}
3
votes

You can use Regular Expression Extractor to get the whole response and save it to a JMeter Variable.

As per How to Extract Data From Files With JMeter guide the regular expression which will match everything looks as

(?s)(^.*)

The whole extractor configuration should look like:

Regular Expression whole body

${response} variable will hold parent sampler response data.