I am trying to seperate the numbers to odd and even and then pass to to the url path using variable in jmeter - json

I have a get request from where I am taking all the id values , using json extractor I have extracted and named it id and used match number as -1
Now I want to pass this id variable into a post url paths
And this post requests are set inside a for each controller to run for required no of iterations
I have given for each controller values as
Input variable : id
Start index : 0
End index : ${id_matchNr}
Output var name : outid
Paths arelike
Post Path 1: https://demo.qwe.com/blue${outid}
Post Path 2:
https://demo.qwe.com/blue${outid}
I want to pass only even id numbers to path 1 and odd id numbers to path two
So I have used if controller and gave expression as
${outid}%2==0 to first path
And ${outid}%2!=0 to other if controller and placed the path 2 request
And checked the interpret condition
These two rqsts are in for each controller.
When I run the script I am getting a blank output for the post rqsts.
Can you please help me out

The function or variable you put in the If Controller must evaluate to true, only this way the If Controller will run its children. In your case you're providing just a string.
You need to wrap it into i.e. __jexl3() function like:
${__jexl3(${outid}%2==0,)}
this way it should work as expected.
More information: 6 Tips for JMeter If Controller Usage

Related

I am trying to get a dynamic value from the response data and use that dynamic value to pass in the url path so the next get method can use it

I am new to jmeter
The response data is
I want to take contentId from the above response and pass it at the end of other get url path so as to get data which is under that content id and I have to use it for multiple users who have different contentId. So how could I dynamically pass it?
Add JSON Extractor as a child of the request which returns the above response and configure it as follows:
name of created variables: anything meaningful, i.e. contentId
JSON Path Expressions: $.contentId
That's it, in the next request path field just use ${contentId} variable where required:
More information:
JSONPath - Getting Started
API Testing With JMeter and the JSON Extractor
Functions and Variables

How to get multiple ids from JSON and pass it to next request in jmeter

please find the attached json:
"0":"10000267",
"no":"10000267",
"1":"2180100151-1-40",
"article_no":"2180100151-1-40",
"2":"550053",
"agent_code":"550053",
"3":"103896",
"customer_code":"103896",
"4":"A+",
"grade":"A+",
"5":"1336489",
"id":"1336489",
"6":"8907679958231",
"ean_code":"8907679958231",
"7":"315",
"quantity":"315",
"8":"27",
"available_quantity":"27"
},
{
"0":"10000286",
"no":"10000286",
"1":"2180100151-1-40",
"article_no":"2180100151-1-40",
"2":"550108",
"agent_code":"550108",
"3":"112230",
"customer_code":"112230",
"4":"A+",
"grade":"A+",
"5":"1432890",
"id":"1432890",
"6":"8907679958231",
"ean_code":"8907679958231",
"7":"494",
"quantity":"494",
"8":"27",
"available_quantity":"27"
Now i have extracted "id" using JSON extractor and i have to pass these multiple ids in next request . How can i do this?
For Eg: I have to pass id in next request in this format id=1432890,1336489.How can i achieve this.If any one add a code that can help to achieve this it would be great.
Call the variable by their names in the next request like ${varJson_1},${varJson_2}. So, in the next request id=${varJson_1},${varJson_2}.
If you are using json extractor to fetch multiple values then below screenshot will help you to get all the values in one variable. Then, in the next request call that variable.
As shown below, foo_All contains all the values fetched by the json in one variable. Use this in the next.
Hope this helps.

how to run particular http request to multiple times in jmeter?

I've multiple http samples in Test Plan but i want to run only one request for multiple times based on csv data set config and remaining http requests will run once particular sample is complete all the iteration based on csv data set config.
In above image i've 5 http samples and i've csv data set for first request,once first request is run for entire csv data set test data then another samples should run,please provide solution how to perform this type of operation in jmeter.
you can use Loop Control and provide the number of hits you needed.
To go to Loop Control:
Right click on the Thread/ThreadGroup
Click on Add
select the Logic controller
Select the Loop Controller
According to the problem, there is a need to execute a particular request to execute in a loop. The loop could be organized in the following way.
-> Thread Group
-> Loop Controller
-->Particular Request
-> Other Request
The CSV Dataset could be found in Config Element and should contain a path to a particular file with data (e.g. accounts.csv).
Both elements could be located in
Loop controller: Add ->Logic Controller -> Loop Controller
CSV Data Set : Add -> Config Elements -> CSV Data Set Config.
The loop can run for the exact amount of records in a file if
Loop Count is equal to a number of strings in the accounts.csv
Forever, it could be stopped by Test Duration automatically or by Stop button.
The CSV Data Set config should have a path to a file with data.
If a file contains headers, then Variables will be assigned based on column names from first string, otherwise, it is necessary to provide variables names in configuration.
ANSWER: If you use 9 variables and all of them are set as header names in a file, then don't provide them in CSV Data Set Config. They will be created automatically, so you can use all 9 variables through names in your file.
If headers are not provided, set 9 all in a Variable Names field, using comma as separator.
Configure your CSV Data Set Config like:
Reference name: foo
Recycle on EOF: false
Stop thread on EOF: false
Put the CSV Data Set Config under the While Controller and put ${__javaScript("${foo}" != "<EOF>",)} into "Condition" input
Add If Controller under the While Controller and put "${foo}" != "<EOF>" into the "Condition" input
Put your first request as a child of the If Controller
Replace foo with your actual JMeter Variable reference name everywhere in the script.
This way JMeter will loop until there are entries in the CSV file and will proceed with the remaining requests when the end of CSV file will be reached.
See Reading all Values from the CSV and Continue chapter of the Using the While Controller in JMeter article for more detailed information on configuring JMeter for your scenario.
You can verify with only one variable and Rest variable you don't required in If and while controller.

Unable to pass jmeter post call's dynamic response to get call

am new to JMeter. I hit the multiple "post" calls with the different data sets. Every post call results in unique id as the response. I want to again pass the each unique id to "get" call with 5 mins interval. I have extracted the unique id by regex extractor. The problem is, I can only pass the last unique id to "get" call instead of every unique id. Is there a way we can create dynamic regex-key and downstream the value for further use?enter image description here
There are certainly multiple ways in which you could solve for this. To name a couple:
Capture each of the different POST response ID's as unique variables, which could then be used in future GET calls, each requesting with one of the unique ID's.
Example: ID1, ID2, ID3, etc...
Create separate thread groups for each of these POST/GET scenarios. The JMeter variable will only be local to the thread group, so they will be isolated from one another. This would also provide the possibility of running them concurrently if so desired.
Using a variable (a count of sorts) to increment on each POST, and appending it to a common variable name.
Example: ID${count} . You would have to add a Beanshell Preprocessor to increment the count variable within each HTTP Request Sampler.
int count = Integer.parseInt(vars.get("count"));
count = count + 1;
vars.put("count", count.toString());
You could then iterate until reaching the value of count in a While Controller when making the GET requests, or you could decrement count. Both would serve the same function, provided the condition in the While statement is satisfied. Additionally you could use a Loop controller with count as the # of iterations, and simply have another count that increments for the life of the loop.
Probably the easiest way will be using an incrementing postfix like:
Add __counter() function as a postfix for your "Reference Name" like
Each time the Regular Expression Extractor will be called, a new batchid_N variable will be created where N is an incrementing number produced by the __counter() function
You will be able to access these variables values as ${batchid_1}, ${batchid_2}, etc. where required. There is also a possibility to use another JMeter Function or Variable as the postfix value via __V() function like:
${__V(batchid_${yourVar})} - combine "batchid_" prefix with ${yourVar} variable
${__V(batchid_${__counter(,)})} - combine "batchid_" prefix with __counter() function
See How to Use JMeter Functions article series for more information on above and others JMeter functions.

Drupal 8 - JSON API get with parameters

I can get the list of records I have of a custom content by creating a new "view" and setting the response returned in a JSON format
Now I would like to send a get request, with 1 or more parameters, and only return a subset of records whose fields match with my parameters
ex : www.exmample.com/rest/view/customcontent?city=paris
How could I do that ?
You can create a filter (add filter criteria) in the view. Make it exposed and change the Filter identifier field according what you want to have in the URL.