How to get response message HTTP Request on Beanshell Jmeter

14,549

Solution 1

It is as simple as

prev.getResponseMessage();

where prev is a shorthand to parent SampleResult class

Demo:

Beanshell Response Message Demo

See How to Use BeanShell: JMeter's Favorite Built-in Component article for more information on using Beanshell in JMeter

Solution 2

You can also use context(ctx) variable to get the previous result data:

ctx.getPreviousResult().getResponseCode();
ctx.getPreviousResult().getResponseHeaders();
ctx.getPreviousResult().getResponseData();
Share:
14,549
Hendrione
Author by

Hendrione

Updated on June 25, 2022

Comments

  • Hendrione
    Hendrione almost 2 years

    Hi actually I want to test web service using Jmeter. but I am stuck when I want try to get response message from http request. actually I want to get the response message from beanshell post processor. How should I do to get the response code?

  • Hendrione
    Hendrione over 7 years
    thank you, it works. but I use this method to get the response message prev.getResponseDataAsString()
  • Hendrione
    Hendrione over 7 years
    thank you. it works too... it shoild be alternate way to get responsedata
  • sravan ganji
    sravan ganji about 5 years
    how to get the required header from response header ? i have 2 set-cookie values ex: set-cookie: _csrf=XSASEDDDS;path=/ set-cookie: X-MY-CSRF=ABcnsfdgsg;path=/