Home > Back-end >  I am trying to get dynamic value of a response variable in an api using jmeter json extractor and us
I am trying to get dynamic value of a response variable in an api using jmeter json extractor and us

Time:02-23

However, I'm unable to get the desired response in assertion. I have used json extractor and given Name of created variable as : contenttype

Json path expression: $..contenttype

Default values: contenttype

And in the response assertion with pattern as substring I have given "contenttype":${contenttype}

But in results I am getting assertion fail message like test expected to contain /"contenttype:":VOD/

CodePudding user response:

We cannot help without seeing:

  1. The response (at least partial)
  2. Your contenttype variable value (can be visualized using Debug Sampler)
  3. The placement of the Response Assertion (I'm talking about Scoping Rules)

So far I can only tell that:

  1. The correct syntax for JMeter Variables is ${your-variable-name-here} so you might want to change your expression to "contenttype":${contenttype}

  2. If the value of the contenttype variable is supposed to be a String - in JSON it needs to be surrounded with quotation marks

    "contenttype":"${contenttype}"

  3. If there are spaces around : like "contenttype" : "VOD" your response assertion will fail

  • Related