{
{"status":
{"id":2,}
}
Next service should be
{
"Data":"ABC"
}
similarly :
set Data = "DEF" if Id = 2 , Data = "GHI" if id = 3
{
{"status":
{"id":2,}
}
Next service should be
{
"Data":"ABC"
}
similarly :
set Data = "DEF" if Id = 2 , Data = "GHI" if id = 3
status
JSONPut 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')
}
Amend your HTTP Request sampler Body Data to look like:
If id
will be 2
- Data
value will become DEF
, if id
will be 3
- Data
will become GHI
References: