简体   繁体   中英

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

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

I faced this issue. What I did wrong, was that I did not put the "$" sign before the parameters in the URL.

How I resolved the issue: When I got the exception, I counted the characters in the URL till the index (given in the exception) which made me realize that something is wrong with the given index, then I checked the tutorial which I was following, and Hoorah. the issue has been found.

Note: I was a newbie in Jmeter.

I hope, it will help you. Good Luck! Example Image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM