okhttp3

Custom HTTP method not working in Retrofit 2

空扰寡人 提交于 2019-12-06 10:49:06
问题 Hello I have used custom method in my code as below but it always gives me java.lang.IllegalArgumentException: method AUTH must not have a request body. My code is not working it always says: Custom method AUTH, must not have a Body @Headers("Content-Type: application/json") @HTTP(method = "AUTH", path = "login/{deviceId}", hasBody = true) Call<Success> getLogin( @Path("deviceId") int deviceId, @Body RequestBody password); I am using below dependancies. compile 'com.google.code.gson:gson:2.8

Retrofit 2.0 multiple interceptors

故事扮演 提交于 2019-12-06 07:58:30
问题 I am working with retrofit and need to be able to use multiple interceptors. Currently I am using one to automatically append an auth token but i need to be able to make calls with no auth token. If i add another interceptor with no auth token in the header how do I use that one instead of the auth token interceptor. val interceptor: Interceptor = Interceptor { chain -> val newRequest = chain.request().newBuilder(). addHeader("Auth_Token", pref.getString(PSPreferences.prefAuthKey, "")).

ExceptionInInitializerError in Okhttp.Builder w/ Multidex & Kitkat

旧巷老猫 提交于 2019-12-06 01:41:24
问题 I'm experiencing an ExceptionInInitializerError exception on VM running Kitkat 4.4.2 with Multidex enabled. java.lang.ExceptionInInitializerError at okhttp3.OkHttpClient.newSslSocketFactory(OkHttpClient.java:263) at okhttp3.OkHttpClient.<init>(OkHttpClient.java:229) at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015) at myapp.utils.Utils.getHttpClientBuilder(Utils.java:131) at myapp.fragments.FragmentHome.getHome(FragmentHome.java:326) at myapp.fragments.FragmentHome.onViewCreated

OKhttp : SSLProtocolException: SSL handshake terminated

旧时模样 提交于 2019-12-05 13:47:19
I'm trying to figure out why sometimes I get this error javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x60d46c90: Failure in SSL library, usually a protocol error error:1409443E:SSL routines:SSL3_READ_BYTES:tlsv1 alert inappropriate fallback (external/openssl/ssl/s3_pkt.c:1256 0x60d57f40:0x00000003) the code that makes this request: private <T> void send(final String url, final Map<String, String> args, final RequestCallback<T> callback, final Parser<T> pParser, final Context pContext, final HTTP_METHOD method, final Map<String, String> headers, final BODY_TYPE bodyType) {

okhttp3 RequestBody in Kotlin

China☆狼群 提交于 2019-12-05 10:59:00
I want to send a request body like this : How I send this ? I will send it as a class ? "email":{ "emailto":"foo@bar.com", "emailfrom":"foo@bar.com", "emailcc":"foo@bar.com", "emailbcc":"foo@bar.com", "emailsubject":"Subject", "emailtag":"Information", "emailtextbody":"---", "attachments":[] } val formBody = FormBody.Builder() .add("email", "Your message") .build() val request = Request.Builder() .url(url) .post(formBody) .addHeader("_Token","") .addHeader("Content-Type","application/json") .build() I highly suggest to use Retofit for such case, but if you really need to deal with raw Request

ExceptionInInitializerError in Okhttp.Builder w/ Multidex & Kitkat

♀尐吖头ヾ 提交于 2019-12-05 08:11:16
I'm experiencing an ExceptionInInitializerError exception on VM running Kitkat 4.4.2 with Multidex enabled. java.lang.ExceptionInInitializerError at okhttp3.OkHttpClient.newSslSocketFactory(OkHttpClient.java:263) at okhttp3.OkHttpClient.<init>(OkHttpClient.java:229) at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015) at myapp.utils.Utils.getHttpClientBuilder(Utils.java:131) at myapp.fragments.FragmentHome.getHome(FragmentHome.java:326) at myapp.fragments.FragmentHome.onViewCreated(FragmentHome.java:135) I have the following libraries: implementation 'jp.wasabeef:recyclerview

OkHttp support for SDK versions less than 21

亡梦爱人 提交于 2019-12-05 06:23:48
OkHttp has recently dropped support for Android 4 , except via a separate 3.12.x branch that will be supported until end of Dec 2020 (and probably receive no more than critical updates or bugfixes). On the assumption that you wish to continue to support Android 4, like I do, since 10% of the Android user base is still a significant proportion, and don't want to be stuck in a dead-end branch... Rather than being stuck on the 3.12.x branch for all sdk versions, is there any way of using the 3.12 branch for sdk < 21 and the 3.13 branch for sdk >= 21 , a bit like it would of course be possible to

Several new Proguard issues Google Play services v10.2.6 to v11.0.0 in a Multidex project

本秂侑毒 提交于 2019-12-05 02:57:26
I updated our app to use the most recent Android Firebase SDK v11.0.0 ( https://firebase.google.com/support/release-notes/android#20170607 ) and out of the suddenly we bunch of new proguard errors appear, FYI everything was working well before with proguard. Before: compile 'com.google.firebase:firebase-messaging:10.2.6' compile 'com.google.android.gms:play-services-vision:10.2.6' After: compile 'com.google.firebase:firebase-messaging:11.0.0' compile 'com.google.android.gms:play-services-vision:11.0.0' The issue is that it doesn't seem to be a simple new missing proguard entry, but it seems

how to get response body in okhttp when code is 401

拜拜、爱过 提交于 2019-12-05 02:45:20
i am using okHttp 3.2.0 and here is code for building request object MediaType JSON = MediaType.parse(AppConstants.CONTENT_TYPE_VALUE_JSON); RequestBody body = RequestBody.create(JSON, requestBody); HttpUrl url = new HttpUrl.Builder() .scheme("http") .host("192.168.0.104") .port(8080) .addPathSegment("mutterfly-server") .addPathSegment("j_spring_security_check") .addQueryParameter("j_username", jsonObject.getString("emailId")) .addQueryParameter("j_password", jsonObject.getString("password")) .build(); request = new Request.Builder() .addHeader(AppConstants.CONTENT_TYPE_LABEL, AppConstants

HTTP/2 protocol not working with okhttp

走远了吗. 提交于 2019-12-04 23:35:05
I am using Retrofit 1.9 with okhttp 2.4.0. So far we have SPDY protocol disabled on server side (I checked it by this ). And enabled protocol on server side is HTTP/2 (I checked it by this ). So I was thinking that okhttp will try to make an api call using HTTP/2 (latest one protocol) but it's using HTTP/1.1 on android device 4.2.2 samsung S4 - D/Retrofit : OkHttp-Selected-Protocol: http/1.1 Someone told me that android device doesn't support SPDY until 5.0 (I don't have any proof), so that device never attempted to use a SPDY connection. But I am sure that our server not using SPDY at all I