syed naveed
syed naveed

Reputation: 95

Encoding query parameters in rest assured

I am using rest assured to automate get request. I have below query param which i want to encode. I googled and found URLEncoder.encode(String) to encode my query parameter which is working but i am getting warning as "encode is deprecated. Can you please help which is the latest method i can use to encode my query param. Your help is appreciated. Thanks in advance

*String queryParam =
                "profiles/employee eq 'test1' and id eq 'test'";
        String restUrl = URLEncoder.encode(queryParam);*

warning: encode(java.lang.String)' is deprecated

Upvotes: 0

Views: 1464

Answers (1)

Rob Evans
Rob Evans

Reputation: 2874

You need to provide a second parameter to give the character-set to use for the encoding to take place:

String restUrl = URLEncoder.encode(queryParam, StandardCharsets.UTF_8);

Should work

https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html Second method is listed below the deprecated one you're using.

Upvotes: 1

Related Questions