Parveen Y
Parveen Y

Reputation: 101

how to handle Special character in query param value in Rest assured

I'm struggling with handling special character in query parameter value while working with Rest Assured.

In url (as given below), I have to pass the value which is separated with pipe symbol '|'. I encoded symbol with value %7C however service call doesn't not give matching response instead returns default response.

http://localhost:8080/api/abc?Id=7325860%7CXYZ

Interesting part is same url works fine with any browser rest client or other java based solution.

Upvotes: 8

Views: 14087

Answers (1)

Johan
Johan

Reputation: 40510

REST Assured performs URL encoding for query parameters by default. You can easily disable it though:

given().urlEncodingEnabled(false).when().get("http://localhost:8080/api/abc?Id=7325860%7CXYZ");

See documentation for more info.

Upvotes: 28

Related Questions