JMeter - Unable to click Parameter tab when added Body Data - jmeter

Why I cannot click on Parameters tab in HTTP Request section after I insert JSON body data in Body Data tab? I tried to define correlation and of course this will require us to define the variable as well. Just wondering, after I'm done with correlation part, how can I insert the variable in Parameters if it is disabled?

You can't send Parameters and Body Data, you must choose only one option of sending request body
If you need to send extra parameters in additional to request body then use query parameters in Path field, for example
path?parameter1=value&parameter2=value2

If you want to variablize/correlate the JSON request body - you can put the relevant JMeter Functions/Variables directly into "Body Data" tab
as you can see all the functions/variables are getting replaced by their respective values.
Also most probably you're getting JSON as the response so it makes sense to consider switching to JSON Extractor or even better JSON JMESPath Extractor for the correlation.

Related

post data with value showing valid response data but same value from regular expression is not showing valid response data in jmeter

When manually entering value in below parameters, it's working fine and showing a valid response.
Below post shows data when values are manually entered:
POST https://qatbagp523.unix.gsm1900.org/wcs/resources/store/11151/quoteHandler/syncQuote
POST data:
{
"opportunityId":"92456",
"quoteNumber":"54044"
}
[no cookies]
But same value captured from regular expression will not show valid response data
Below post data values captured from regular expression
POST https://qatbagp523.unix.gsm1900.org/wcs/resources/store/11151/quoteHandler/syncQuote
POST data:
{
"opportunityId":"92456",
"quoteNumber":"54044"
}
[no cookies]
Even same post data values but manually entered post data is showing valid response but regular expression captured post data is not showing valid response
I observed headers and other valuesm there is no change, could any please resolve how to get response and what could be the cause for this type of issues
Given you send the same requests you should be getting the same responses, if you have different responses - most probably you're sending different requests
Compare 2 requests using View Results Tree listener, they should be exactly the same in terms of request body, request headers, etc.
Check the variable which is stored by the Regular Expression Extractor using Debug Sampler, it might the case there are extra spaces, line breaks, etc.
Use a third-party external sniffer tool like Wireshark or Fiddler as View Results Tree listener doesn't always tell the full story
If you won't be able to figure out the root cause of the issue - consider saving all the request and response data for both Samplers and update your question with the XML file containing these details.

How to get URL having ".../?where={'key1' : 'value1' , 'key2' : 'value2':.........}" in Jmeter http request

I need to load test one Python api in below URL format:
//IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}
I tried to pass the key value pair through csv as well as directly in http request but getting error message.
java.net.URISyntaxException: Illegal character in query at index 47:
http://IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}
Here key and value are dummy data I have placed here for easy understanding.
Please help me with correct syntax for this URL.
Thanks in advance for all your help.
In REST APIs, JSON objects are typically sent (POST) or returned in the body of the request. They are not typically encoded as part of the URL.
For a GET request, you can either pass the information as segments in the url or as querystring parameters.
For more details refer here, How to send a GET request with a "/" in the query
As per HTML URL Encoding Reference:
URLs can only be sent over the Internet using the ASCII character-set.
so you need to define the request in JMeter's HTTP Request sampler as follows:
Pay attention to URL Encode? checkbox, it has to be ticked otherwise the parameter will be sent "as is"
Another option is using __urlencode() function like:
http://IP:PORT/Sub_Part/?where=${__urlencode({"KEY1":"VALUE1"\,"KEY2":"VALUE2"\,"KEY3":"VALUE3"})}
which will generate an encoded sequence which you could use in the URL path:
%7B%22KEY1%22%3A%22VALUE1%22%2C%22KEY2%22%3A%22VALUE2%22%2C%22KEY3%22%3A%22VALUE3%22%7D
as you can see, all non-ASCII characters where removed.
Check out Apache JMeter Functions - An Introduction to learn more about JMeter Functions concept.

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.

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.

Capture a header value from the response in Jmeter and re-use

I'm calling a REST request for authentication. And I need to get the session ID sending on response; in order to reuse that in my next request.
session id comes in Response header. When I use view result tree, this is not showing header parameters(response body has no data).
When googling I found a method using Regular expression Extractor method, but seems it works only when data in response body.
Nope, Regular expression extractor can search in headers also. You need to specify where to search.
See example,
This will search in headers and you can specify in main samples, sub samples also.

Resources