I'm trying to Open the connection using okhttp.
something like,
urlConnection = client.open(url);
does not work with the new ok-http.jar file.
It was working with 1.5.x of okhttp version
Any suggestions?
Thanks
I'm trying to Open the connection using okhttp.
something like,
urlConnection = client.open(url);
does not work with the new ok-http.jar file.
It was working with 1.5.x of okhttp version
Any suggestions?
Thanks
Code from documentation
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://kenumir.pl/")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
Method execute is the key ;-)
What does it means "it does not work"??? Does it fails at compile time or runtime? What kind of error does it shows? As of OkHttip 2.x.x, there's been a change in the way to open HttpUrlConnections, you need to include a new module and this should work:
// OkHttp 1.x:
HttpURLConnection connection = client.open(url);
// OkHttp 2.x:
HttpURLConnection connection = new OkUrlFactory(client).open(url);
see OkHttp Release notes for more information .