Hendrione
Hendrione

Reputation: 255

How to get response message HTTP Request on Beanshell Jmeter

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?

Upvotes: 4

Views: 21114

Answers (2)

Dmitri T
Dmitri T

Reputation: 167992

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

Upvotes: 2

Svp57
Svp57

Reputation: 318

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

ctx.getPreviousResult().getResponseCode();
ctx.getPreviousResult().getResponseHeaders();
ctx.getPreviousResult().getResponseData();

Upvotes: 5

Related Questions