Get Http Status Code with OkHttp

You can use HttpResponse class and using that you can access the status code as follows;

HttpResponse httpResponse = client.newCall(request).execute(); 
httpResponse.getStatusLine().getStatusCode();

If you are using com.squareup.okhttp.Response then you can use the code() method to get the HTTP status code.

Response httpResponse = client.newCall(request).execute(); 
httpResponse.code();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)