Rafiq Shaikh
Rafiq Shaikh

Reputation: 113

JMeter - Access JSR223 variable in HTTP sampler

I have a variable in JSR223 and I need to call that variable in HTTP sampler. For example, I have a variable as mentioned below.

Jsondata = ''' {
    "name": "Foo Bar",
    "year": "2018",
    "timestamp": "2018-03-08T00:00:00",
    "tags": [
        "person",
        "employee"
    ],
    "grade": 3.14
}
'''

I'm calling the variable in body data of HTTP request sampler like below, but it's printing itself and not converting to actual value.

${Jsondata}

The output which i am getting in result tree is ${Jsondata}

Upvotes: 1

Views: 658

Answers (1)

Ori Marko
Ori Marko

Reputation: 58772

In JSR223 script put groovy variable value into JMeter variable using vars

vars.put("Jsondata", Jsondata);

Upvotes: 2

Related Questions