com.android.okhttp.internal.http.HttpURLConnectionImpl cannot be cast to javax.net.ssl.HttpsURLConnection
Method1:Your urlString must begin withhttps:// and not http://for you tobe able tocast it toaHttpsURLConnection.
Method2:if your urlString starts withhttp://, changing HttpsURLConnectiontoHttpURLConnection should work