Jmeter Http proxy server throws java.net.URISyntaxException: Invalid character in request when index error

I am trying to record a connection with a web client and server using Jmeter. After setting up Jmeter and browser to record the application. When a mail request is executed from client to server, the following error occurs. Any idea how to encode the url that is being written?

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) 
+7
java put urlencode jmeter
source share
1 answer

In particular, this exception applies to curly braces in your URI:

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

Curly braces are considered unsafe :

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

Thus, you can replace all instances of { with %7B and all instances } with %7D . I assume that the recorder does not encode them, because curly braces are not โ€œspecialโ€ characters (they are just โ€œunsafeโ€), while they do not like the URI parser. Thus, you can consider it a mistake in the JMeter recorder. Thus, the minimum solution is to set the Path :

 /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 that a more elegant solution saves all the parameters (behind the label ? ) In the Parameters section, which has several advantages:

  • It has the ability to automatically encode them
  • You can clearly see what parameters you are sending.
  • You can use variables when you need static values โ€‹โ€‹instead (you can also in the Path, but not without a lot of tiresome and error-prone configurations).

Here is a screenshot of how I will create this request:

enter image description here

Since the Method parameter is set to GET , all parameters will be included in the URL anyway, but they will be correctly encoded, so here is how it is sent:

enter image description here

+2
source

All Articles