Reputation: 1
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.
Upvotes: 0
Views: 2883
Reputation: 168157
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.
Upvotes: 2