0

I'm trying to use the JSON Extractor in JMeter 5.1 to get at a value (an id) in a ReactJS app so that I can use this value in the URL of an api call to a DELETE.

My JSON payload looks something like this:

[
    {"id":14530,"name":"gjqawkierp",},
    {"id":14529,"name":"yuhtvzlalg",},
    {"id":14527,"name":"kcnicnptox",},
    {"id":14526,"name":"dahyoeeobe",},
    {"id":14520,"name":"temp",},
    {"id":14511,"name":"fghffdd",},
    {"id":0,"name":"None"}
]

I know the name and have this as a named variable ${RNAME} by adding "name":"${__RandomString(10,abcdefghijklmnopqrstuvwxyz,RNAME)}" into the body data of one of my post requests.

I'm now trying to make a follow up DELETE and the id in the JSON payload is used in the URL path. So I'd call /api/names/14530/ with the DELETE method to delete this generated item where I replace the static number in the URL with a variable.

However, in the JSON extractor, if I try to create a variable RID with a JSON Path Expression of $.id[?(@.name == '${RNAME}')] the RID variable is always blank in the Debug sampler so my DELETE URL looks like /api/names//

Maybe someone knows whether you can do this, Google searching has failed me here as has the JMeter documentation as it's very sparse in it's description of this extractor.

0

Okay, so $..[?(@.name=='${RNAME}')].id actually works and the debug sampler was showing a match with RID_matchNr=1 but I was getting an empty match because I hadn't set my Match No. under the JSON path expression to 1 which says the first match.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.