7

I am trying to record my web client-server communication using Jmeter. After the Jmeter and browser are configured for recording the application. When a post request is made from client to server, the following error happens. Any idea how to encode the URL which is being recorded?

java.net.URISyntaxException: Illegal character in query at index 238: http://localhost:8080/updateBoxCorrectionInstantly?examKey=16-17-%3ECBSE-%3ETERM%20I-%3ESA1-%3EVI-%3EScience-%3EA&studentName=AMOGH%20YOGESH%20KALE&studentRollno=3&studentND=-1&sheetName=cb8e806b32e9d670698655e0d2da10e3_img001210.jpg&box={%22$center%22:%22(66.0,%202253.0)%22,%22$conf%22:%22H%22,%22$corrected%22:true,%22$isAdminCorrected%22:true,%22$correction%22:%22-%22,%22$isDrawn%22:false,%22coords%22:[36,2214,96,2292],%22isTitle%22:false,%22pos%22:%22-%22,%22pred%22:%22-%22,%22boxTypeId%22:0,%22score%22:1}
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parseHierarchical(URI.java:3092)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:949)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:232)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1075)
at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:212)
3
  • This might help you: meta.stackexchange.com/questions/79057/curly-brackets-in-urls Commented Feb 6, 2017 at 11:47
  • this happened during recording or replaying? did you try using http://jmeter.apache.org/usermanual/functions.html#__urlencode function? Commented Feb 6, 2017 at 12:09
  • is your request actually 'POST' ? why are you sending so many url parameters for post request? Could you not send them as part of request body using formurlencoded request property? Commented Feb 6, 2017 at 23:12

2 Answers 2

2
+50

Specifically that exception is about curly braces in your URI:

/updateBoxCorrectionInstantly?<...>_img001210.jpg&box={

Curly brackets are considered unsafe:

Other characters are unsafe because gateways and other transport agents are known to sometimes modify such characters. These characters are "{", "}", "|", "\", "^", "~", "[", "]", and "`". All unsafe characters must always be encoded within a URL.

So you could replace all instances of the { with %7B, and all instances of } with %7D. My guess is that recorder is not encoding them because curly brackets are not "special" characters (they are just "unsafe"), while URI parser does not like them. So you can consider it a bug in JMeter recorder. Thus minimal solution is to set Path to:

/updateBoxCorrectionInstantly?examKey=16-17-%3ECBSE-%3ETERM%20I-%3ESA1-%3EVI-%3EScience-%3EA&studentName=AMOGH%20YOGESH%20KALE&studentRollno=3&studentND=-1&sheetName=cb8e806b32e9d670698655e0d2da10e3_img001210.jpg&box=%7B%22$center%22:%22(66.0,%202253.0)%22,%22$conf%22:%22H%22,%22$corrected%22:true,%22$isAdminCorrected%22:true,%22$correction%22:%22-%22,%22$isDrawn%22:false,%22coords%22:[36,2214,96,2292],%22isTitle%22:false,%22pos%22:%22-%22,%22pred%22:%22-%22,%22boxTypeId%22:0,%22score%22:1%7D

However, I think a more elegant solution is saving all parameters (past the ? mark) in Parameters section, which has few advantages:

  1. It has an option to automatically encode them
  2. You can clearly see which parameters you are sending
  3. You can use variables when you need to instead of static values (you can in Path as well, but not without a lot of tedious and error-prone configuring)

Here's a screenshot of how I would create this request:

enter image description here

Because the Method is set to GET, all parameters are going to be part of URL anyways, but they will be properly encoded, so here's how it's sent:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

So, the solutions can be any one of the following 1. Encode the URL in application 2. Record the request and format the request again before starting the recorded sequence
0

try using $ before every {}.Thanks

1 Comment

While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.