Passing a variable from a response to a request in JMETER

It is necessary to transfer data from the response to a subsequent request. Something is wrong, and the default value of the variable appears in the request.

The first request returns JSON in the response body, which looks like this:

{"issued_at":"2016-01-14T12:41:01.000Z","expires":"2016-01-14T12:46:01.000Z","id":"j6M ... MTA=="}
enter image description here

I am retrieving the id attribute value using Extractor Regular Expression Extractor:

enter image description here

Then I pass the variable tokento the following query parameter:

enter image description here

But the request is created with the default value of the variable:
enter image description here

+4
source share
3 answers

There is a JSON Path Extractor designed to work with the JSON content type, I believe it would be easier to use it.

JSON Path , $..id

. XPath Extractor JMeter ( "Parsing JSON" ) JSONPath - XPath JSON JSONPath .

Regular Expression Extractor:

  • 1
  • $1$
+4

, . $1 $ .

+2

The problem was resolved by setting the Check Field switch to Body in the Regular Expression Instance dialog box and setting the Pattern field to $ 1 $. Thanks alphamikevictor and Dmitri T for the help!

+2
source

Source: https://habr.com/ru/post/1624279/


All Articles