Add a Key for Request Body in JMeter - json

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

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

I have been trying to add a dynamic value in the url path of an api in Jmeter script from response code of other api. Help me out

I have an api which has many folder to it and each folder have more than two contents and I want to compare each contentid in folder from response code with other duplicate api response code which has same contents as this api in Jmeter
For eg. The folders are in a path something like https://apple.test.com/user/folder(just an example url)
To extract each folder I have used json extractor for above url in http request and extracted the folder id (with json path as $..folderid...if I select ALL in the extractor and try to use ${folderid_ALL} in url path I am getting an error), then created another http request and passed this variable in the url something like
https://apple.test.com/user/folder/${folderid}
And used beanshell assertion to compare their contentid
When I execute this only the first folder is picking up and it's contents are compared and rest of the folders are not shown
Can you help me out on how to extract all the files and compare their contents!!
If you have multiple folder IDs extracted into JMeter Variables using JSON Extractor you can use ForEach Controller to iterate all the IDs.
Also since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so consider migrating to the JSR223 Assertion
In order to get the comprehensive answer you should include:
The JMeter Variables generated by the JSON Extractor
The format of the "next" request for the "folder"
The response you're getting
What do you want to compare with what

JMeter to test java rest Api

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

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.

jmeter load testing , Parameterization

I am running a HTTP request test in jmeter where I send a json input. For example:
{ "id":"0", "fieldvalue":"sanket","Source":"todays date" }
I need to parametrize this so that for each thread iteration a different value for id, fieldvalue, source is chosen, possibly from a json file only (not CSV file). Is this possible?
Everything is possible. Here are the options
JMeter can read almost any files. Check out the following functions:
__FileToString()
_StringFromFile()
You can also use HTTP Request sampler to read the file, just use file as protocol and UNC path.
Values for parametrization can be obtained using JSON Path PostProcessor. See:
JSONPath - XPath for JSON - for JSON Path language overview and syntax
Advanced Usage of the JSON Path Extractor in JMeter - for some not obvious scenarios covered