JMeter to test java rest Api - json

How can i pass the json for post method if my json is like:
{
"REQUEST":{"REQUEST_BODY":{"Account_Name":"ak"}}
}
It gives me an error at time of parsing json value
In postman it run properly

In HTTP Request use Body Data tab and of course fill-in Server Name, Port Number, Path and Update Method if needed:
And under HTTP Request add a Header Manager:
And add to it required headers:
Note Content-type might be different for you.

If your request works in Postman you can just record it in JMeter:
Configure JMeter for recording, the fastest way is using JMeter Templates feature
From JMeter's main menu choose File - Templates - Recording - Create
Expand Workbench - HTTP(S) Test Script Recorder and click "Start
Configure Postman for recording. You can "tell" Postman which proxy server to use (JMeter in your case) via --proxy-server command-line argument
C:\Users\your_user_name\AppData\Local\Postman\app-x.x.x\Postman.exe --proxy-server=localhost:8888
Execute your request in Postman
JMeter will capture the request and store it under Test Plan - Thread Group - Recording Controller
References:
Apache JMeter proxy Step-by-step
How to configure Postman Native Client App to use an external proxy

Related

How to send a GET request with JSON body in JMeter?

I am facing some issues as JMeter doesn't take the JSON body passed as a parameter. I tried through postman and it was working fine but for Jmeter it is not working
I am expecting a response from get request with JSON body in Jmeter
We're not telepathic enough in order to suggest you how you can fix your "some issues" without knowing the details of the "issues"
JMeter can send the GET request with the JSON (or any other) body
If the request works in Postman and doesn't in JMeter most probably you're not sending the same requests, the most common mistake is that people forget to add a HTTP Header Manager configured to send correct Content-Type header.
Just use a 3rd-party sniffer tool to intercept requests originating from JMeter or Postman, identify the difference(s) and amend your JMeter configuration so the requests would be exactly the same. Alternatively just record the request from Postman using JMeter's HTTP(S) Test Script Recorder

Response code: 418 'I'm a teapot' in jmeter

I've been trying to test the API of restful-booker in Jmeter. But whenever I try to create a booking or Get a Booking by id I'm getting the HTTP response:418 'I'm a teapot'.If I try to access the URL in the browser it says the same. But when I run this in postman it does not give any kind of error. Also, it shows the correct response in Code Beautify. Really frustrating. Is there any way to resolve it?
If you're capable of successfully executing the request in postman (or whatever else tool) and not able to do it with JMeter most probably you're sending a different request.
Check out literally everything: URL, headers, body, etc. - all matters.
There are 2 approaches:
Use a 3rd-party sniffer tool like Fiddler or Burp to capture the requests from postman and JMeter and compare them for differences
Or just record the request from Postman using JMeter's HTTP(S) Test Script Recorder, JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
Problem is here: you forgot add accept: application/json in jmeter, postman automatically adds this setting.

Add a Key for Request Body in JMeter

I am running a Performance Test in JMeter
So in my case I need to give a Request Body as a Json String along with a key called 'json'
I cant find a way on JMeter to provide a key when passing the Request Body like Postman
ex : Key Value
json {some JSON String}
What I have tried in JMeter :
Postman API Call :
Just switch to "Parameters" tab where you will have Postman-like style definition of the request parameters in form of name-value pairs
Going forward, given you can successfully execute the request in Postman you should be able to record the request using JMeter's HTTP(S) Test Script Recorder, just configure Postman to use JMeter as the proxy:
and if your request assumes test.pdf file upload make sure to copy this file to the "bin" folder of your JMeter installation

How to use JSON variable of GET request in other HTTP request?

I'm really new in JMeter.
Tenant has Multple Environments
I have a test plan to create a Tenant, Get the tenant list. And then i have a JSON Extractor to save the Tenantid in order to create automatly an Environment in the desired tenant.
JSON Extractor:
then I set a Header manager to use the ID of this tenant to create the Environment in the Tenant
My HTTP request is set like this
[enter image description here][3]
But it doesn't work. Can you point me what i'm doing wrong?
Double check that your JSON Extractor works via Debug Sampler and View Results Tree listener combination. You should see tenantId variable value there. See How to Debug your Apache JMeter Script article for more details.
If you really need to send PATH HTTP Header make HTTP Header Manager a child of the next HTTP Request sampler to avoid any clash with other HTTP Header Manager instances. Mind that URL Path is not the same as HTTP Header named PATH
Check jmeter.log file for any suspicious entries.

Track navigation with jmeter

I try to make a stress test with jmeter: i set up jmeter proxy to record navigation and everythings is ok.
I have some problem with a page wich has a json request called by javascript: using the jmeter proxy this request doesn't works.
With firebug I can see that the response of json request is
{"error":{"msg":"couldn't parse request arguments","code":590}}
It seems that jmeter proxy modify the parameter request.
With this error, I cannot use this page: any suggest?
Thanks
Aldo
JMeter isn't able to execute JavaScript, you'll need to construct the request manually. Perhaps you'll need to get some parameter(s) from page source via Regular Expression Extractor. Once you figure out correct request make sure that you'll add Content-Type header application/json via HTTP Header Manager