0

I need to load test one Python api in below URL format:

//IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}

I tried to pass the key value pair through csv as well as directly in http request but getting error message.

java.net.URISyntaxException: Illegal character in query at index 47:
http://IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}

Here key and value are dummy data I have placed here for easy understanding.

Please help me with correct syntax for this URL. Thanks in advance for all your help.

Nipun Tharuksha
  • 2,496
  • 4
  • 17
  • 40
govind
  • 25
  • 5

2 Answers2

0

In REST APIs, JSON objects are typically sent (POST) or returned in the body of the request. They are not typically encoded as part of the URL.

For a GET request, you can either pass the information as segments in the url or as querystring parameters.

For more details refer here, How to send a GET request with a "/" in the query

SAIR
  • 479
  • 3
  • 9
0

As per HTML URL Encoding Reference:

URLs can only be sent over the Internet using the ASCII character-set.

so you need to define the request in JMeter's HTTP Request sampler as follows:

enter image description here

Pay attention to URL Encode? checkbox, it has to be ticked otherwise the parameter will be sent "as is"

Another option is using __urlencode() function like:

http://IP:PORT/Sub_Part/?where=${__urlencode({"KEY1":"VALUE1"\,"KEY2":"VALUE2"\,"KEY3":"VALUE3"})}

which will generate an encoded sequence which you could use in the URL path:

%7B%22KEY1%22%3A%22VALUE1%22%2C%22KEY2%22%3A%22VALUE2%22%2C%22KEY3%22%3A%22VALUE3%22%7D

as you can see, all non-ASCII characters where removed.

Check out Apache JMeter Functions - An Introduction to learn more about JMeter Functions concept.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133