Ghost
Ghost

Reputation: 569

Groovy JMeter Passing a string with spaces, avoiding %20

I have an API which it's URL requires a string with spaces --> A B C I have tried

String X = "A B C";
vars.put("myKey",X);

GET  https://myserver.com/Api/v1.0/config/${myKey}   

When JMeter executes this it replaces spaces with %20 in url. I do not want JMeter to repalces spaces with %20, how can I do that

GET https://myserver.com/Api/v1.0/config/A%20B%20C

Upvotes: 1

Views: 603

Answers (2)

Vadim Yangunaev
Vadim Yangunaev

Reputation: 1991

Usually browser replaces spaces entered into the address bar with %20. So do JMeter.

You have to update your API, so URL param with %20 should be interpreted as a string with a space(s) by your API.

Upvotes: 1

Ori Marko
Ori Marko

Reputation: 58772

You can't send space in URL:

A URL must not contain a literal space. It must either be encoded using the percent-encoding or a different encoding that uses URL-safe characters (like application/x-www-form-urlencoded that uses + instead of %20 for spaces).

But you can use + instead of space

And notice that server/receiving end will decode it back to spaces so there isn't a real issue.

Upvotes: 2

Related Questions