Using JSON extractor inside a WHILE controller in JMETER - json

I want to get JSON response which appears after some time of running a sample till then it is null, after some time it gives a "filestore_id" that is some random number. I am enable to write the condition in while loop for the loop to run till there is no null in the JSON response and extract the filestore_id from the JSON response which can be then used in a sample outside of that while loop.enter image description here
The file store id for loop 1 gives null.After some loops it gives some id number when the total records=recordscompleted.
Attached screenshots
Attached screenshot
Attached screenshot

The "condition" would be a __jexl3() function like:
${__jexl3("${filestore_id}" == "null",)}
I cannot give you either JSON Path or JSON JMESPath Expression because you preferred to post your JSON response as the image, it could be something like:

Related

Jmeter 5.5: extract and store ID value from json response body whose json is in string format

enter image description hereI want to extract id value from json body whose partner join value is Yes
Response body sample:
{"data":{"data1":"{"recommendedPrograms":{"recommendedProgram":[{"id":"xxxxxxxx","programName":"ProgNme1","programNameLocal":"Prog Test","programDescription":"ProgDesc1","programDescriptionLocal":"Prog level1","partnerJoin":"No","priority":1,"version":"v5"},{"id":"yyyyyyy","programName":"ProgNme2","programNameLocal":"Prog Test2","programDescription":"ProgDesc2","programDescriptionLocal":"Prog level2","partnerJoin":"Yes","priority":1,"version":"v6"},{"id":"zzzzzzzzzz","programName":"ProgNme3","programNameLocal":"Prog Test3","programDescription":"ProgDesc3","programDescriptionLocal":"Prog level3","partnerJoin":"No","priority":1,"version":"v7"}]}"}}
Issue:
Since jsonbody is in string format so not able to extract id value directly using json extractor.
Any lead on this will be highly appreciated.
Can anyone help me with beanshell or groovy script to handle id extraction.
Please refer image screenshot for response body sample as back slash is getting removed in the description .
What you posted as the text version is not a valid JSON, you won't be able to use either JSON Extractor or Groovy for working with it, you will need to go for i.e. Regular Expression Extractor
I will give you a hint: if you have JSON which is inlined into JSON object you could
Extract data1 attribute value into a JMeter Variable using JSON Extractor
Then you could use another JSON Extractor to extract what you need from data1 JMeter Variable

Masking json response payload

I want to know how can we create a REGEX to mask below value of content against Created By key in response received from REST API.
\\\"CreatedBy\\\":{\\\"content\\\":\\\"abcd#test.com\\\"}
So output which I am expecting is
\\\"CreatedBy\\\":{\\\"content\\\":\\\"****#****.***\\\"} OR
\\\"CreatedBy\\\":{\\\"content\\\":\\\"*************\\\"} which is getting logged in output logs.
The one which I created by taking reference of other
(?<=\\\\"CreatedBy\\\\": \s*{\\\\"content\\\\":\\\ "*)
but this is not working, can anybody help me on this

Jmeter : I am using Json extractor to pass value from the Json response but I am not seeing the value in the debug sampler

I am trying to pass the values of the basketId and basketItemId from the Create Basket Json response to Jmeter variable so that I can use these values in the next requests. I set up everything according to the documentation, however I am not able to see the values in the debug sampler in the Tree - Response Data area. Any help is appreciated?
You're not seeing your values because your sampler hasn't been executed
It has not been executed because you need to provide the same number of the "Default Values" as the variables you declared. If you look at jmeter.log file you will see something like:
Mismatch between number of variables, json expressions and default values
The solution would be adding the default values like:
null;null
And assuming your Json Path expression matches something in the response you will see both values.
More information: API Testing With JMeter and the JSON Extractor

How do I parse a JSON from Azure Blob Storage file in Logic App?

I have a JSON file in Azure Blob storage that I need to parse and insert rows into SQL using the Logic App.
I am using the "Get Blob Content" and my first attempt was to then pass to "Parse JSON". It returns and error": InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2856'"
I found some discussion that indicated that the content needs to be converted to a string so I used "Compose" and edited the code as suggested to
"inputs": "#base64ToString(body('Get_blob_content').$content)"
This works but then the InvalidTemplate issue gets pushed to the Parse function and I get the InvalidTemplate error there. I have tried wrapping the output in JSON expression and a few other things but I just can't get it to parse.
If I take a sample or even the entire JSON and put it into the INPUT of the Parse function it works without issue but it will not accept the blob content as JSON.
The only thing I have been able to do successfully from blob content is to take it as a string and update a row in SQL to later use the OPENJSON in SQL...but I run into an issue there that is for another post.
I am at a loss of what to do.
You don't post much information about your logic app actions, so maybe you could refer to my flow design. I test with a json data with array.
The below is my flow picture. I'm not using compose action, and use decodeBase64(body('Get_blob_content')['$content']) as the Parse Json content.
And if select property from the json, you need set the array index. I set a variable to get a value 'body('Parse_JSON')1['name']'.
you could have a try with this, if still fail, please provide more information or some sample to let us have a test.

Jmeter - How to read multiple values returned by GET request in the form of array in Json format and write it to a CSV file

Jmeter - I have multiple values ( 250 values approx as a minimum ) returned from a Get Request in the form of array in json format , i need pass each of the value in the array as a parameter in next GET request
Request 1
> Get http://xxx/store1?
Response in json format looks like this
{"store1":"peirre","inventorylist":["item1","item2","item3"..........."item250"]}
I will need to use each one of item in next GET request like this to get is feautures like price , available quantity,production site etc.,
Request 2
Get https://xxx/store1/item1?
Get https://xxx/store1/item2?
Get https://xxx/store1/item3?
It would be easy when i can read the response and write each value in the array to CSV file so that my next get request would simply read the CSV file and fire all the requests
Is there a way to achieve this ???
Thank you in advance
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. item
JSON Path Expressions: $.inventorylist.*
Match No.: -1
Add ForEach Controller after the first HTTP Request sampler and configure it as follows:
Input variable prefix: whatever you used as "Names of created variables" in the JSON Extractor, i.e. item
Output variable name: anything meaningful, i.e. current_item
Add HTTP Request sampler as a child of the ForEach Controller and use https://xxx/store1/${current_item} in "Path" field - it will iterate through all the "item"s
Add a Json Extarctor to the first Get Request with the following properties
2.Add a JSR223 post processor and initialize a counter as shown below
Add a while controller and place your get request in while controller.
add the following condition
${__javaScript(parseInt(vars.get("counter"))<=parseInt(vars.get("List_matchNr")))}
as shown below
To your second get request add a JSR223 post processor and increment the counter as shown below
int counter = Integer.parseInt(vars.get("counter")) +1;
vars.put("counter",Integer.toString(counter));
Use ${__V(List_${counter})} to replace hardcoded value
This loop will run through the match number and sends a request with each item to server
For more information on while loop please follow the link