How to prepare POST data from a previous HTTP response? - http-post

I've used Fiddler to capture these HTTP calls. Here's the problem:
I have a HTTP-POST data that looks like below:
Notice how it has many 'employeeIds' and also 'shiftSumIds'.
Now, these Ids are from a previous HTTP response that looks like below:
Is there an easy way to extract those Ids and prepare the POST data? Thanks in advance.
--Ishti

Short answer is JSON Path Extractor available via JMeter Plugins which is designed for getting "interesting" values from JSON data. See Using the XPath Extractor in JMeter guide (look for "Parsing JSON" chapter) for installation instructions and some form of JSON Path language reference.
If it is not enough and you will need some assistance in constructing JSON Path query and building HTTP Request from it - please include text version of response and request using i.e. http://paste.org service as reading large amount of text from small screenshot isn't very handy and chance of getting the answer is minimal

Related

Unable to extract the data from previous response in jmeter

I have a situation where the request saves the data using PUT method. The dynamic content is webkit(json body). So kindly help me how to capture the value.
Thanks
Roshan
If you want to extract value(s) from the previous response the options are in:
Boundary Extractor - if you provide a JMeter Variable name and empty left and right boundaries - it will store the whole response into that variable
JSON Extractor - allows extraction of partial data using JSONPath query language
JSON JMESPath Extractor - the same as point 2 but uses a different language - JMESPath which is is more "standard" and powerful
More complex extractions/transformations can be done using JSR223 Test Elements and Groovy language
We cannot "kindly help you" more without seeing the previous response and the next request, the only "help" I can provide so far is a piece of information that WebKit is a browser engine so I have a doubt regarding your statement about sending it somewhere.

How to add a variable from Json extractor into an array in JMeter?

I'm new here and also a beginner on JMeter and maybe this was already answered in an old post that I didn't find, sorry if this is the case.
I had this Post request I need to send with all these IDs that vary according to the account
Post Request
In order to get all of the IDs, I used the JSon extractor to put then into a variable
JSon extractor, then I got all the FieldIDs that I need.
ID extracted
But now how can I add this variable inside the request? I tried something like {"ids":"${fieldId}","includeBoundary":true} but it didn't work. How can I use this?
Please see: HTTP Request parameter dialog example
If you need to extract the whole response, save it into a JMeter Variable and send it back to another endpoint - the easiest way is using Boundary Extractor providing empty left and right boundaries
If you need more complex transformations - take a look at JSR223 Test Elements and Groovy language
I solved my problem in a so easy way(damn it)!!!!
On the Json extractor I just marked the option "Computer concatenation var (suffix_ALL)" then on the debbuger I got all IDs I needed in only one line and finally on my request I just add on the body data the line {"ids": [${fieldId_ALL}],"includeBoundary":true} and bingo it worked like a charm!!!!

How to parameterized request if getting recorded script like this.? See details

How to parameterize request if I am getting something similar to the following for login POST request in body data tab.
"{\"msg\":\"method\",\"method\":\"login\",\"params\":[{\"user\":{\"username\":\"testuser\"},\"password\":{\"digest\":\"5811c74a581ffdb892ab9eddfb9cf2d21772a98332a59de6aa26989e01f84057\",\"algorithm\":\"sha-256\"}}],\"id\":\"7\"}"]
It's generally easy to correlate when we are getting in Parameters TAB, but in cases how we can proceed? For all further requests - it's the similar case.
I tried to switch to Parameters TAB, but it says that it can not be converted to that format.
So How we can proceed?
The same way, just substitute hard-coded (recorded) values with the relevant JMeter Variables directly in the request body like:
"{\"msg\":\"method\",\"method\":\"login\",\"params\":[{\"user\":{\"username\":\"${username}\"},\"password\":{\"digest\":\"${password}\",\"algorithm\":\"sha-256\"}}],\"id\":\"${id}\"}"]
The most commonly used for parameterization test element is CSV Data Set Config, however other options exist.

how to format JSON response in Jmeter?

How can I format json response in jmeter?
I don't want to tell which part of json answer
should be showed. I want to see my response not as
very long one line but as many lines formatted with new lines and
tabs/spaces.
I saw:
http://eclipsesource.com/blogs/2014/06/12/parsing-json-responses-with-jmeter/
Jmeter extracting fields/parsing JSON response
Thanks in advance!
I believe JSON Formatter PostProcessor is what you're looking for
If it is not suitable for you - take a look at JSR223 PostProcessor, it provides prev pre-defined variable (basically SampleResult instance) which gives read/write access to the parent sampler(s) response data so you will be able to do anything you want with the response using Groovy language

JSON Path Extractor in JMeter

I am new to jmeter. Can anyone help me to use a response object of one request to be passed as a request header of next HTTP request ?
Let me explain.
I am getting an access token along with the response of login in my app:
{: "responseCode":18, : "message":"Successfully logged in.", : "responseObject":"8zWExE4eSdhcJDwnW9MgIw=="}
No I want to use this access token (8zWExE4eSdhcJDwnW9MgIw) as one of the parameter of next request.
I used JSON Path Extractor for this.But its not working.
I am using JSON Path Extractor as well and it works great if it is properly configured.
Just put it into request and fill fields:
Variable Name: access_token (or any other you want to use later in request like this ${access_token})
JSON Path: responseObject should be enough if the JSON you pasted is full response (thjose additional colons are just some mistakes when copy-pasting or the JSON is corrupted?)
Default Value: I always use some value like 'NotUpdated!' here so I can assert in the next step or at least see it easily in request.
Not seeing the full response it is quote hard to come up with a correct JSON Path expression.
Given what you posted it should be something like $.responseObject
See JSON Path Syntax guide for queries syntax examples and Using the XPath Extractor in JMeter (scroll down to "Parsing JSON") for plugin installation instructions and XPath to JSON syntax mapping.
Just in case anybody would face an issue with multiple variable extractions using JSON Extractor (like me), make sure to:
List the names of variables/path expressions/default values using a semicolon as a separator.
Provide default values for every variable.
The second point is apparently required, and I only found out about it from this
Medium post.

Resources