0

I am trying to pass the below line in my URL

metadata={"occasion":[{"metavalue":"day-casual"}],"fit":[{"metavalue":"slim"}]}

But when I run the test, am getting error as below

java.net.URISyntaxException: Illegal character in query at index 220: at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.checkChars(URI.java:3021) at java.net.URI$Parser.parseHierarchical(URI.java:3111) at java.net.URI$Parser.parse(URI.java:3053) at java.net.URI.(URI.java:588) at java.net.URL.toURI(URL.java:946)

I guess the problem is with the string with special characters am trying to pass in the URL.

Can someone please help me to encode and send.

1 Answer 1

2

As per RFC 3986 an URL can contain only of digits, letters, and a few graphic symbols, to be more precise:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=

any other characters, i.e. { and } must be URL-encoded

If you need to use JSON structure as a part of URL query string you need to wrap it into __urlEncode() function like:

${__urlencode(metadata={"occasion":[{"metavalue":"day-casual"}]\,"fit":[{"metavalue":"slim"}]})}

Check out Apache JMeter Functions - An Introduction article to get familiarized with the JMeter Functions concept.

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

1 Comment

I tried using the above syntax, but am still getting error. java.net.URISyntaxException: Illegal character in query at index 211: productId=0004cdacf29b4168a7a0f2c9c4ea3e56&channel=test&majorSince=1&minorSince=0&majorUntil=7&minorUntil=9999&gender=Women&{__urlencode(metadata={"occasion":[{"metavalue":"day-casual"}],"fit":[{"metavalue":"slim"}]}&category_name=skirts at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.checkChars(URI.java:3021) at java.net.URI$Parser.parseHierarchical(URI.java:3111) at java.net.URI$Parser.parse(URI.java:3053)

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.