Reputation: 1
in the first thread, I received JSON (format - {"id":6054,"name":"Jmeter created chat","description":"jmeter created test"})
I want to use it in the second thread variable '6054'
I use BeanShell Assertion with code:
${__setProperty(("id":"(.+?)"), ${chat_id)};
but it, of course, doesn't work, please tell me the right way..
many thanks
Upvotes: 0
Views: 66
Reputation: 168072
So
Remove your Beanshell Assertion
Add JSR223 PostProcessor as a child of the request which returns the above response
Put the following code into "Script" area:
props.put('chat_id', new groovy.json.JsonSlurper().parse(prev.getResponseData()).id as String)
In 2nd Thread Group access the value using __P() function as:
${__P(chat_id,)}
Demo:
More information regarding what these prev
and props
guys mean can be found in the Top 8 JMeter Java Classes You Should Be Using with Groovy article
P.S. You may find Inter-Thread Communication Plugin easier to use
Upvotes: 2