Search code examples
javajmeterperformance-testingjmeter-5.0jmeter-3.2

java.net.URISyntaxException: Illegal character in query at index on JMETER


I have an application for which I have recorded Jmeter scripts to conduct load testing. Authorization happens via Azure AD.

I have co-related the auth-related such as access tokens, refresh tokens and id tokens that are generated dynamically and also parameterized them in a request that is responsible for calling the API and which would probably require those tokens to authorize the call to the API.

However, I get an error:-

java.net.URISyntaxException: Illegal character in query at index 98:
    at java.base/java.net.URI$Parser.fail(URI.java:2938)
    at java.base/java.net.URI$Parser.checkChars(URI.java:3109)
    at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3197)
    at java.base/java.net.URI$Parser.parse(URI.java:3139)
    at java.base/java.net.URI.<init>(URI.java:623)
    at java.base/java.net.URL.toURI(URL.java:1063)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:615)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1281)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1270)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:630)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.base/java.lang.Thread.run(Thread.java:832)

I am not sure where I am going wrong. I have co-related 3 dynamic tokens which are generated as part of the auth token request.

Screenshots in the below link:-

Regular Expression Extractor

Setting parameters

Error on Jmeter


Solution

  • I believe these "tokens" should go into the HTTP Header Manager as placing them as request parameters adds them to the request URL.

    If your application expects the tokens to be a part of the URL (which is kind of strange) then you either need to tick the URL Encode? boxes or wrap the values which can contain the characters requiring encoding into __urlencode() function