JMeter - Filter in JSON Extractor by JMeter Variable

  • 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:


    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[?( == '${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.

  • Okay, so $..[?('${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.

Log in to reply

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2