Reputation: 799
I need to test rest api posting Json. I try to post Json Data by BeanShell PostProcessor using Jmeter. But BeanShell PostProcessor doesn't work or I couldn't write the right code.
My Json is : {"email":"[email protected]","password":"123"}
You can see in the pictures below what i did.
Upvotes: 2
Views: 10205
Reputation: 3210
I have used Ralf Sternberg’s slim JSON parser for Java as it is described here.
This is maven dependency of it's current version:
<dependency>
<groupId>com.eclipsesource.minimal-json</groupId>
<artifactId>minimal-json</artifactId>
<version>0.9.4</version>
</dependency>
Don't forget to add this library to Jemeter's lib directory.
Upvotes: 0
Reputation: 2482
I think you wanted to make an http request on an api. Follow this steps.
You can add JSON data manully like shown on the picture.
This gist includes BeanShell Post Processor Version
Upvotes: 4
Reputation: 168122
in.
There is a couple of problems with your Beanshell Sampler code:
\"
So if you amend your Beanshell Sampler code as follows:
String dummyJson = "{\"email\":\"[email protected]\",\"password\":\"123\"}";
SampleResult.setResponseData(dummyJson.getBytes("UTF-8"));
everything should be fine from Beanshell perspective.
See How to use BeanShell: JMeter's favorite built-in component guide for more details on Beanshell scripting in Apache JMeter.
Upvotes: 1