I found a solution to this problem after several attempts. Maybe someone will find this useful.
"Httpurl.Builder".
HttpUrl mySearchUrl = new HttpUrl.Builder()
.scheme("https")
.host("www.google.com")
.addPathSegment("search")
.addQueryParameter("q", "polar bears")
.build();
URL :
https://www.google.com/search?q=polar%20bears
URL :
Request request = new Request.Builder()
.url(mySearchUrl)
.addHeader("Accept", "application/json")
.method("GET", null)
.build();
: https://square.imtqy.com/okhttp/3.x/okhttp/okhttp3/HttpUrl.html