-1
{
    {"status": 
    {"id":2,}
}

Next service should be

{
    "Data":"ABC"
}

similarly :

set Data = "DEF" if Id = 2 , Data = "GHI" if id = 3
Banana
  • 2,435
  • 7
  • 34
  • 60

1 Answers1

0
  1. Add JSR223 PostProcessor as a child of the request which produces this status JSON
  2. Put the following code into "Script" area:

    def id = com.jayway.jsonpath.JsonPath.read(prev.getResponseDataAsString(), '$..id').get(0).toString()
    switch (id) {
        case '2':
            vars.put('Data', 'DEF')
            break;
        case '3':
            vars.put('Data', 'GHI')
    }
    
  3. Amend your HTTP Request sampler Body Data to look like:

    JMeter JSON Body Data

  4. If id will be 2 - Data value will become DEF, if id will be 3 - Data will become GHI

References:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133