0
votes

I am making dme2 call to api from beanshell and i am getting response from it like {"stagedcustomerId":"165ce369-a9fb-4d42-b8f0-f119a6ae20eb"} so now i want to pass only customer id value to another beanshell sampler for next api call as one of parameter in request body in same thread in jmeter.

Please suggest what can we do in this case. is there any way to do beanshell postprocessor?

1
are you getting the response from beanshell sampler , could you please share the snapshot of your test plan so that i can provide exact solution for your queryRohit

1 Answers

0
votes
  1. You can use SampleResult shorthand in order to define the Beanshell Sampler response data like:

    SampleResult.setResponseData("{\"stagedcustomerId\":\"165ce369-a9fb-4d42-b8f0-f119a6ae20eb\"}","UTF-8")
    
  2. Once done you can add a JSON Extractor as a child of the Beanshell Sampler and configure it like:

    enter image description here

  3. That's it, now you will be able to access the extracted value as String id = vars.get("id"); in other Beanshell Sampler or as ${id} in any other test element.

    enter image description here


Also be aware that starting from JMeter 3.1 it's highly recommended to use JSR223 Test Elements and Groovy language for scripting so consider refactoring your test on next available opportunity.