Unable to Send Json parameter as part of GET Request in Jemeter - jmeter

I am using Jmeter to load test with 100 users
This is a REST Call using GET
As part of my request i am sending 3 parameters
ordersplitjson
customer_id
homedelivery
The ordersplitjson parameter is a JSON Value (somewhat big)
This is the request , captured from the browser and the same works when pasted in the browser directly
http:/localhost:8080/OMS/oms1/orderinsertservice?ordersplitjson={"highPriceVendor":"VC4%20Raj","vendors":{"T1":[{"item_ids_":"194","contact_phone_no_":"9876543210","name":"VC4%20Raj","contact_address":"Kukatpally,%20Hyderabad","leaf":[{"contact_phone_no":"9876543210","SurCharges":"50","vendorname":"VC4%20Raj","count":"0","contact_email":"rajk#gmail.com","discount_div":"10Rs","itemid":"194","strikeprice_cutoff":"110","name":"Popcorn%20Regular%20%20%20300%20ML%20Fountain%20Apple","quantity":"1","contact_address":"Kukatpally,%20Hyderabad","date_time":"18:10:19","email_id":"raj#hmail.com","toppings":[],"screen":"SCR-3","seat_num":"D12","customer_name":"Ganesh","image":"images/icon-print.png","contact_person":"Kiran","item_description":"Item%20description","vendor_id":"9","crusts":[],"Vat":"70","customer_mobil":"9090987878","price":"100","mobile_number":"1234567898","ServicesCharges":"50","orderid":"14101519"}],"vendor_id":"9"}]}}&customer_id=22&homedelivery=Yes
But under Jmeter , i am always getting error
java.net.URISyntaxException: Illegal character in query at index 64:
These are my screen shots
Could anybody please help me how to resolve this ??

Your HTTP Sampler Settings & HTTP Header settings should be same as the attached pictures below
Hope this will help.

Related

JMETER 5.2.1 : Why parameters tab is disabled in some of the requests and how to handle requsts in this case

I am new to JMETER , I am trying to record my web application and correlate JSESSION IDs and other details.
JSESSION ID , i want to capture from previous request and send as parameter in next request.
But in the next request parameters tab is disabled. I see in some posts that body should be empty to have parameters tab.
In the attached screenshot , if I make body empty , how do I pass the parameters.can anyone please help me . I am not able to proceed further
If you're testing a REST API and want to parameterize the contents of your payload you can just inline the relevant JMeter Function and/or Variable directly into the request body like:
{"sessionId":"","ipAddress":"","autoLogin":"N","numberLoginAttempts":0,"cookie":"JSESSIONID=${JSESION}"}
If you will still be experiencing problems use Debug Sampler and View Results Tree listener combination in order to check that:
Your JSESION variable exists
It has expected value

Passing a mobile number from a CSV with spaces as a param to Jmeter HTTP GET request

New to Jmeter, I want to pass a variable of say "1234 567 8910" from a CSV file as a Param value to a HTTP GET request and I just can't seem to get it to work, tried a number of ways, any ideas ?
Complains with "java.net.URISyntaxException: Illegal character in query at index 71" which is the first space in the param.
Fixed by changing the csv file.....
If you need to pass this phone number as a GET request parameter just tick URL Encode? box in the HTTP Request sampler:
If you need to pass this phone number as a part of a GET request URL path - you can use __urlencode() function to wrap your variable from the CSV file:
${__urlencode(${variableFromCSV})}
Check out Apache JMeter Functions - An Introduction article to get familiarized with JMeter Functions concept.

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 capture signalR connection string in Jmeter

I am getting error when script is executed in jmeter, because of signalr connection
I need to pass connectionToken and connectionData in the url as below.
"/Web/signalr/connect?transport=longPolling&clientProtocol=1.5&connectionToken=${connectionToken}&connectionData=${connectionData}"
i am able to capture ConnectionToken and passing that successfully. but, i am facing issue with connectionData, which looks like
[{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}]
How to capture and pass this.
Please find the screeshots
! enter image description here
! enter image description here
! enter image description here
! enter image description here
not able to capture below connection string
connectionData: [{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}]
get method sends above connectionData as
GET //abc.com/Web/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D&_=1522754518635
and am getting the response connectionToken. i am able to extract connectionToken .
now, i need to send
GET //abc.com/Web/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&tid=10&connectionToken=%27FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU%2BP9fDasBFDTA%2B78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG%2BCsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc%27&connectionData=%255B%257B%2522name%2522%253A%2522alertshub%2522%257D%252C%257B%2522name%2522%253A%2522loggerhub%2522%257D%252C%257B%2522name%2522%253A%2522notificationhub%2522%257D%255D%26_%3D1522754518635
It has valid connectionToken(extracted) but not the connectionData.
Response is Unexpected character encountered while parsing value: %. Path '', line 0, position 0.
my question is how can i get this values, [{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}].
and next i need to post
POST //abc.com/Web/signalr/connect?transport=longPolling&clientProtocol=1.5&connectionToken=FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU+P9fDasBFDTA+78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG+CsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc&connectionData=%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D&_=1522754518635
as you can see here, it has valid connectionToken but not connectionData.
Response for this is : The ConnectionId is in the incorrect format.
BlazeMeter1
Blazemeter2
Blazemeter3
You need to use the same method as you have used for connection token.
It seems like your variable is not getting the required values. Are you using the same variables between two thread groups?
**-->Here request is encoded and connection data is also encoded.**
GET //abc.com/Web/signalr/negotiate?clientProtocol=1.5&connectionData=**%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D**&_=1522754518635
and am getting the response connectionToken. i am able to extract connectionToken .
now, i need to send
**-->Here again encoded connection data is further encoded.**
GET //abc.com/Web/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&tid=10&connectionToken=%27FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU%2BP9fDasBFDTA%2B78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG%2BCsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc%27&connectionData=**%255B%257B%2522name%2522%253A%2522alertshub%2522%257D%252C%257B%2522name%2522%253A%2522loggerhub%2522%257D%252C%257B%2522name%2522%253A%2522notificationhub%2522%257D%255D%26**_%3D1522754518635
If I got it correct, then avoid encoding twice. In first and second screenshot you are encoding it twice.
If "connectionData" is fixed then try "User defined variables" or if it is available in some response then capture there using regular expression and use it further.
I hope you are not getting error during data extraction.

How to capture and use the dynamic value generated in the same service in Jmeter?

I have recorded a script, where a dynamic value (user_token) is generated. The same value has to be used in the same service. The previous services before this service are using GET methods, so I was not able to use regular expression before the service.
Please find the screen shot of the script.
Would you please confirm on the below.
If your script is recorded . then the current sampler what you attached, what it tells to us is , The user_token is populated automatically while recording . i.e., initially login.html was recorded with username and password you provided , then next sampler signin.html recorded with additional user_token
between login.html and signin.html samplers, you got your user_token ,i.e., login.html response contains user_token ,so would you please add regex post processor to login.html http sampler and try accessing the "user_token" value to a variable and use that variable in Signin.html
I have used the regular expression in login.html as suggested by Suman. Yes it is capturing the value and passing it to the next samplers.
Here im receiving an another problem after execution.
Im receiving the below error:
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
Please find the screen shot.
error

Resources