0
votes

I have 2 requests. In one request I have used the random text generator and generated some random string and passed that to a variable. After that a new record is created with than random name and unique ID is created. I want to fetch the ID of that record. How do I extract that using JSON extractor.

EG.

Srno name id 1 xvyhz 1230-1236(some id) 2 abczz 1230-1236(some id)

I want to get the ID of the 'abczz' which is created by random string generator function and stored in 'variablename' variable. So how to extract the ID of that generated string using JSON extractor.

1
Please format your question so JSON is clearly visible and validDmitri T
{ "locationApportionments": [ { "groupLocationId":null, } ], "meters": [ { "meterId":"8ea69980-5771-4650-af37-37dff115a9d7", "meterName":"xyzio", }, { "meterId":"aa2618ec-00a1-4962-93cf-71b142e9bb4c", "meterName":"abcio", } ], "productions":null, }rutujit diwate
@DmitriT : Above is the json response. In that the meter name is created with the random string function. And the meterid is created once the record is saved. I have saved randomly generated string in one variable 'meterid' So how to extract the meter id with this variable 'meterid'rutujit diwate

1 Answers

0
votes

If you are looking for meterId attribute value where meterName is abcio the relevant JSON Path expression will be something like:

$..[?(@.meterName == 'abcio')].meterId

Demo:

JMeter JSONPath Conditional Select

More information: API Testing With JMeter and the JSON Extractor