Getting Illegal character in path at index 53 in POST Request - jmeter

I am trying to POST HTTP request and request is not going thru. what am I doing wrong or missing?
I think it does not like this part
colonoscopy.jpg/1-1?
Server name: ${hostName}
Path: ${virtualDirectory}/data/media/${location}/colonoscopy.jpg/1-1?&prodName=${prodName}&otherParams=&sid=${authToken}
HTTP Header Manager
Content-Type application/x-www-form-urlencoded
Getting
Thread Name: Thread Group 1-1
Sample Start: 2019-02-01 15:39:06 PST
Load time: 0
Connect Time: 0
Latency: 0
Size in bytes: 1681
Sent bytes:0
Headers size in bytes: 0
Body size in bytes: 1681
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: Non HTTP response code: java.net.URISyntaxException
Response message: Non HTTP response message: Illegal character in path at index 53: http://10.188.169.185/api/v2/data/media/dc2e83cfe2054
Server:%20Microsoft-IIS/10.0
Set-Cookie:%20ASP.NET_SessionId=5cwq0inclxwvmd0qlnd01yo3;%20path=/;%20HttpOnly
X-AspNet-Version:%204.0.30319
X-Powered-By:%20ASP.NET
Access-Control-Allow-Origin:%20*
Access-Control-Allow-Headers:%20Content-Type,Authorization
Access-Control-Expose-Headers:%20Content-Location,%20Location
Access-Control-Allow-Methods:%20GET,%20POST,%20OPTIONS,%20DELETE
Date:%20Fri,%2001%20Feb%202019%2023:39:05%20GMT
Content-Length:%200
colonoscopy.jpg/1-1?&prodName=test&otherParams=&sid=ca1bc7a576a44d9b8270b7cac2dddab8
HTTPSampleResult fields:
ContentType:
DataEncoding: null

Inspect your URL along with the query string using View Results Tree listener, the error can have only one reason: you're sending a character which requires URL encoding as it is.
The reasons are in:
One of your variables (${location}, ${prodName} or ${authToken}) has the character which requires the URL encoding. If this is the case - you will need to wrap it into __urlencode() function
One of your Variables (${location}, ${prodName} or ${authToken}) is not getting resolved into the value and curly braces characters ({ and }) are not allowed in the URL string without encoding. Use Debug Sampler to make sure that :
all the variables have their values
all the characters which require the encoding are encoded using the __urlencode() function

Related

Not able to extract value from the response and use it in next request using JSON extractor

Here is the reponse and i want to extract the id from it
{"status":"success","data":{"name":"chirag","salary":"1000","age":"30","id":82}}
this is how i am trying to extract:
then use it in the next request like this:
Update:
When i use this in this in the next request - api/v1/delete/${id}, I get this error:
Thread Name:Delete Employee 5-1
Sample Start:2020-07-19 11:27:54 WEST
Load time:0
Connect Time:0
Latency:0
Size in bytes:1115
Sent bytes:0
Headers size in bytes:0
Body size in bytes:1115
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:Non HTTP response code: java.net.URISyntaxException
Response message:Non HTTP response message: Illegal character in path at index 47: http://dummy.restapiexample.com/api/v1/delete/${id}
To Extract... modify the "json path expression" as:
$.data.id OR $..id
Then in subsequent request, correct the path:
/api/v1/update/${id}

JMeter cannot assert Http response Code 423

I'm trying to assert http response codes in JMeter.
I think this is really simple, but I encountered a problem I cannot fix.
My server can return 2 response codes: 200 and 423.
There is no problem with 200, it just works, but I cannot assert 423, I don't know why.
I tried response assertion with the following configurations:
Field to test: Response Code,
Pattern Matching Rules: Contains
Patterns to test:
200 - works
423 - does not work
200|423 - 200 works, 423 does not work (wtf?)
I also tried BeanShell Assertion with
Failure = !(ResponseCode.contains("200") || ResponseCode.contains("423"));
It does not work, too.
Also I tried to match with the response message to contain "Locked" - does not work.
The server Response looks like this:
Thread Name: 10 Users, 100 Repeats 1-10
Sample Start: 2017-05-19 13:06:09 MESZ
Load time: 33
Connect Time: 2
Latency: 33
Size in bytes: 333
Sent bytes:768
Headers size in bytes: 333
Body size in bytes: 0
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""):
Response code: 423
Response message: Locked
Response headers:
HTTP/1.1 423 Locked
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
X-Application-Context: application:capacitytest
Content-Length: 0
Date: Fri, 19 May 2017 11:06:08 GMT
Server: Not_available
HTTPSampleResult fields:
ContentType:
DataEncoding: null
The response code is marked blue for a reason in Sampler Result. Don't know why.
I'm also logging the response code via Beanshell PostProcessor. It is 423...
Finally I'm asking here for your help.
I have no idea what the problem is or could be.
Thanks in advance.
If you are talking about HTTP Request sampler JMeter automatically threats HTTP Status Codes above 400 (inclusively) as failed. I would recommend the following setup:
Add Response Assertion as a child of your HTTP Request
Configure it as follows:
Apply to: according to your test scenario
Fields to test:
Response Code
Don't forget to check Ignore Status box
Pattern Matching Rules: Matches
Patterns to Test: 200|423
Assuming above configuration if the status of your request will be 200 OR 423 - it will pass, otherwise it will get failed by the assertion.
See How to Use JMeter Assertions in Three Easy Steps guide for comprehensive information regarding JMeter Assertions.

JMeter: Body & File content

The WebAPI request has a POST method which expects Content body. I've tried to use both Parameters and Body options but I receive error responses - 'Invalid Request' with 400 Status code, etc.
JMeter request Sample Content Body:
{
"ParamA": 111,
"ParamB": "Char String",
"ParamC": "VarType"
}
OR
{ "ParamA": 111, "ParamB": "Char String", "ParamC": "VarType"}
Listener Request:
POST data:
--8vpH3B6WcV4f1La46_wccVi4c25lrLJaGcN--
Listener Response:
{"message":"The request is invalid.","modelState":{"value":["An error
has occurred."]}}
Any insight into viable options? Eventually, I'm planning on reading the Body string from a .csv file so I can parameterize the request. Reading from a .CSV file only reads the first line of the request body - for example: '{'
Any help would be greatly appreciated.
Best,
Ray
HTTP Request
Request
Uncheck in HTTP request the option:
Use multipart/form data for POST
Also check your CSV does not contain some data that contains the CSV separator which is '\t' by default.
Ensure it doesn't by changing separator to '|' for example if you're sure your JSON will never contain it.

Jmeter- soap-xml sampler request

I am using jmeter, I am very new to it and have min programming background.
I am currently using 2 sampler: a) soap Request b) soap xml rpc request.
Uisng the soap request sampler, I can easily load the wsdl file and continue my testing.
RESPONSE
But unable to do so with 'soap xml rpc request' sampler
the message I am getting here is
a:ActionNotSupportedThe message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
SAMPLER RESULT
Thread Name: Thread Group 1-1
Sample Start: 2013-09-27 15:03:07 BST
Load time: 7
Latency: 7
Size in bytes: 698
Headers size in bytes: 0
Body size in bytes: 698
Sample Count: 1
Error Count: 1
Response code: 500
Response message: Internal Server Error
Response headers:
HTTP/1.1 500 Internal Server Error
Content-Length: 698
Content-Type: text/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Sep 2013 14:03:07 GMT
Connection: close
HTTPSampleResult fields:
ContentType: text/xml; charset=utf-8
DataEncoding: utf-8
It could be simple - just uncheck the 'Send SOAP Action" checkbox in SOAP/XML-RPC request and try again

Regular Expression for Jmeter for http-response header

How to use regular expression extractor to extract Etag from http-header response?
I've the following output from my get and I want to extract Etag and use it in my next case where i've to pass it in my http-header to do If-None-Match. I've tried the following: \Etag:\s? and have chosen "Headers" in "Response Field to Check". But I don't see this value being sent to my header.
Thread Name: Fetch_Links 1-1
Sample Start: 2012-05-24 10:15:10 PDT
Load time: 135
Latency: 131
Size in bytes: 4950
Headers size in bytes: 641
Body size in bytes: 4309
Sample Count: 1
Error Count: 0
Response code: 200
Response message: OK
I'm using 2.6 version of jmeter. Thank you in advance.
I'm able to extract the ETag in JMeter (Regular Expression Extractor - Headers) with the following parameters:
Regular Expression: ETag: "(.*?)"
Template: $1$
Then add a HTTP Header Manager to pass the value of the Etag with 'If-None-Match'.

Resources