How to use all extracted values from JSON Path Extractor in next Http request? - jmeter

i have created a scenario where i log in and extract all the device IDs added in my application. After extracting all device IDs with "JSON Path Extractor" i want to apply one configuration to all devices, using device IDs.
in JSON Path Extractor i am using JSON path as:
$..deviceResponseList[*].id[0]
and Variable name: device_id
in next http request i am calling variable as:
${device_id}
Here if it extracts say 10 device IDs in last Http request its taking only first ID in Http request.
How should i pass every device_id extracted one after other from json path extractor in next http request sampler
NOTE: I am using Rest API for implementation.

This is not possible OOTB with jmeter-plugins.
But you can have a look at :
http://www.ubik-ingenierie.com/blog/easy-scripting-of-json-applications-with-apache-jmeter/
Use our ULP_JSON PostProcessor to extract from the JSON data the elements we want using the variable “data” extracted by previous Post-Processor...
Disclaimer : We are providers of this commercial plugin for Apache JMeter

Related

Use of Json extractor

Im running a test plan containing 10 requests i need to get the variable value from 3rd response json to be passed to request URL of 10 th request passed . any way we can use json extractor to do this?
This can be accomplished by using any of the post processors for correlation in amongst any of the requests. I have shown an example below with JSON Extractor
Request Sample
The value that I am going to extract from 3rd request's response is "I am the value to be fetched from 3rd response"
JSON Extractor
I am using the below syntax in JSON Path Expression to extract data from "valueToBeFetched" json object and storing it in variable named "extractedValue_C"
$..valueToBeFetched
10th Request
Replacing the extracted value with syntax ${extractedValue_C} in 10th request
Output
Response Captured from 3rd Response
Captured value passed in 10th request
Hope this helps!
JSON Extractor obeys JMeter Scoping Rules so if you put it as a child of the 3rd request - it will be applied to 3rd request only.
If you come up with a valid JSONPath matching the value you want to extract - the value will be saved into a JMeter Variable which can be used anywhere after 3rd request (where it is defined or overwritten in next iteration)

How to do statistics on the values extracted from HTTP response header in Jmeter

I'm using Jmeter to test my web server, instead of using the jmeter's default
response time, I'd rather to use one specific header value that I extracted from response header by Regular Expression Extractor, how can Jmeter generate a table or graph base on that value(think that value as the real response time)
Use sample_Variable to generate the required data with simple data writer as csv. Then, replace the response time data generated in that sheet with your custom variable data in the sheet. Then, browser that file in the listeners as per your requirement.

extract the a field value with same name from JSON using JMeter

In the JSON response I have multiple fields with same name inside different tags . But I need to fetch the from that tag where matches the number I want. Say in the below examplele I want to fetch the value "(786)402-9010" when customerPpid=467133011
[{"oopId":"110034477","timestamp":"3698652681958","targetType":"TMTroubleCall","billAccount":"3655732026","customerFormattedPhoneNumber":"(786)505-2911","customerIsRequestingCallBack":"false","customerPpid":"609188407","acceptTime":"03/16/2018 11:31:00","originator":"DPH0GNL","priorityForDisplay":"3","remarks":"test","ddbKey":"8614147890T","displayType":"SNCU","parentFplId":"268224478","parentActualDeviceType":"TXU","parentDdbKey":"8614147890T","parentTroubleCoordinateX":"863634","parentTroubleCoordinateY":"459622","parentPreviousProtectiveDeviceStack":"268221704,23282601,23281142","toldItr":"03/16/2018 14:30:00","toldMode":"N","ticketCallComplaints":[{"componentId":"1685289","description":"No Current"}],"customerLanguageMenuOption":"1"},
{"oopId":"114249429","timestamp":"3698652636567","targetType":"TMTroubleCall","billAccount":"6182150000","customerFormattedPhoneNumber":"(786)402-9010","customerIsRequestingCallBack":"false","customerPpid":"467133011","acceptTime":"03/16/2018 11:31:00","attachTime":"03/16/2018 11:31:00","originator":"DPH0GNL","priorityForDisplay":"3","remarks":"testing","ddbKey":"8614154820T","displayType":"SNCU","parentFplId":"268224477","parentActualDeviceType":"TXU","parentDdbKey":"8614154820T","parentTroubleCoordinateX":"864084","parentTroubleCoordinateY":"459307","parentPreviousProtectiveDeviceStack":"268221704,23282601,23281142","toldItr":"03/16/2018 14:30:00","toldMode":"N","ticketCallComplaints":[{"componentId":"1685289","description":"No Current"},{"componentId":"4063885","description":"Customer checked breaker"}],"customerLanguageMenuOption":"1"},
how should i do it?
Add JSON Extractor as a child of the request which returns the above JSON
Configure it as follows:
Names of created variables: anything meaningful, i.e. phone
JSON Path Expressions:
$..[?(#.customerPpid == '467133011')].customerFormattedPhoneNumber
That's it, now you should be able to access the extracted value as ${phone} where required.
Demo:
References:
JSON Path Operators
JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios
Use the following Json path expression
$..[?(#.customerPpid=="467133011")].customerFormattedPhoneNumber
Add a JSON extractor to the request as shown in the screenshot below
Please follow this Link for more info on extracting variables
Jmeter Json Extractor

How to extract the licensetype and corresponding id using JMeter and pass it to next HTTP API request?

From response need to extract the licensetype and corresponding id (based on licensetype, id changes - ex: licensetype 'full', there can be 20 ids associated, licensetype 'half' can be 100 ids associated). This extracted info needs to be passed to next 'POST' request by passing licensetype and ids as shown in the screenshot.
How to extract this kind of combination using JMeter and pass it to next HTTP API request? I can extract each one like licensetype and ids separately using RegEx or JSON path extractor however I need to specify the combination in the next request. Please guide.
General recommendation: use JSR223 PreProcessor and Groovy language to construct the JSON Payload programmatically using JsonBuilder class. Previously extracted IDs can be accessed using vars shorthand which stands for JMeterVariables class instance.
References:
Parsing and producing JSON
Groovy Is the New Black

In jmeter : how to extract values from two different json response and use that extracted values as a parameter for new http request

In jmeter: I’m using two http requests in one thread group, so I’m getting two response from those http requests.
I need ‘member id’ from one response and some string(digest) from other response, in order to create third http request.
I have extracted 'member id' by using this regular expression: {"Id":(.+?)}
which return me correct member id.
Response from 2nd request is string(digest) : "G9V6Su9PESaobcInErdD7Y8OKNo="
I added one more regular expression to extract this string : "(.+?)"
I have added two debug sampler as I'm using two regular expression extractor.
then I pass extracted values 'member id' and string(digest) as a parameter to third http request.
When I run it I'm getting error, my 3rd http request failed.
It's failing to pass extracted 'member ID', but its correctly pass string(digest)
In first debug sampler: its showing correct extracted 'Member ID' but some different values for digest field.
In 2nd debug sampler: its showing correct extracted 'digest' field but some different value for 'Member ID'.
I’m doing it all under one thread group
I'm new to jmeter, I don’t know whether it is possible to extract field from two different response and use as parameter to create new http request.
if it possible how to do it please help me.
Thanks in advance.
I believe that it's due to including quotation marks (and who knows what else) into the "Id" regular expression, you need to surround it with quotes like:
{"Id":"(.+?)"}
Also the better way of working with JSON data is JSON Path Extractor which is available via JMeter Plugins project. See Using the XPath Extractor in JMeter guide (scroll down to "Parsing JSON") for more information on installation, usage, syntax, etc.

Resources