In JMeter Post Data Not Sent In Request When Certain Character Strings Are Included - jmeter

In a test plan that I am trying to execute, there is a step that includes a post request with post data. One of the parameters in the post data includes special characters. The parameter name is '__RequestVerificationToken'. When the parameter name is spelled correctly, the request is sent with no post data included. The request fails. However when the parameter is changed slightly, post data will be included with the request. Because the correct parameter names are not sent, the request also fails. Below is a list of parameter names that do and do not break the sending of post data.
Parameter names that do break the sending of post data:
'__RequestVerificationToken'
'__RRequestVerificationToken'
'**RequestVerificationToken'
Parameter names that do not break the sending of post data:
'__TRequestVerificationToken'
'RequestVerificationToken'
Is there anything that I can do have my parameter name sent correctly without dropping post data from the request?

Did you try encoding them using 2 options:
In Http Request check the checkbox encode in the parameters table
Use function __urlencode

Related

JMeter - Unable to click Parameter tab when added Body Data

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.

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.

Send Form data and Query string in one POST request in Jmeter

I need to send POST request through jmeter. I have checked the requests workflow through browser dev. tools. In my Post request I need to send form data and one string Query. Question is next - if i will add my string Query to URL will it work fine?
Example : somesite.com/something?refURL=someRef
If it is a POST request, usually any form data will be sent in the request body. Not like a query string in the GET request. But the format is same.
refURL=someRef add this in the parameters section.
Check here for more info.
https://www.w3.org/TR/html401/interact/forms.html#h-17.13
Why not? Query string and request body are different beasts and they are processed differently on server side.
Instead of asking this kind of questions, why don't you just record your test using JMeter's proxy server?
References:
URI Syntax - Query Component
HTTP Method Definitions - POST
Yes it will.
You can even use variables like:
/some/path?refURL=${someCalculatedRefUrl}

JMeter not attaching contents of binary file to POST data in HTTP Request

I'm attempting to simulate a login call with JMeter 2.11 to a service that uses a binary format. I've created an Http Request with the appropriate settings, except for the body data. I need to POST raw binary data.
According to the docs here, I should be able to set the file path for exactly one file, with no parameter name, and no other content in the Body Data, and have it place the data in the request body.
If it is a POST or PUT or PATCH request and there is a single file whose 'Parameter name' attribute (below) is omitted, then the file is sent as the entire body of the request, i.e. no wrappers are added. This allows arbitrary bodies to be sent. This functionality is present for POST requests after version 2.2, and also for PUT requests after version 2.3.
However, when I run the test, the POST Data is empty.
I have tried the extra set of plugins for JMeter as well, but alas, I'm stuck. The loaded file has 145 bytes of data, and the request shows that the content-length is 0. What am I missing?
The Http Request
The result
Update 1
To clarify, I am NOT attempting to send a file, I'm attempting to send a binary encoded message as raw POST data.
Switch back to Parameters tab not Post body.
See:
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Request
Yoy could try recoring to see how the resuest look like.
This is my solution,maybe not best, but it works fine:
1st step :
You should write your binary data to a file (assume it's name is
FILENAME);
2nd step :
For your http request sampler,Yout should put ${FILENAME} under file
path in the "Send Files with the request" section (while leaving its
paramter name empty and specifying an encoding (for binary, it is
application/binary)).
Hope it helps.
Refer to this article

Resources