Search code examples
jmeterresponsepreprocessor

Jmeter extracting the response value and use on the same HTTP Sampler name


Can someone help me extract the name parameter and use that on the same HTTP request name

Example if this is the response I got

{
    "response_time": 0.014376163482666016,
    "applications": [
        {
            "uid": "gta",
            "api_key": "blted0e7982e1cf62a8",
            "account_name": "jack",
            "name": "Testuser"
        }
    ]
}

the name HTTP Request name depends on the name parameter will be generated

Image Description


Solution

    1. Add JSR223 Assertion as a child of the request (as per JMeter Test Elements Execution Order you need something which is executed after the JSON Extractor post-processor)

    2. Put the following code into "Script" area

      prev.setSampleLabel(prev.getSampleLabel() + ' ' + vars.get('name'))
      
    3. That's it, now you will have ${name} JMeter Variable added as the postfix for the sampler name

      enter image description here