Answer the question
In order to leave comments, you need to log in
Why is Retrofit not sending the request?
The API description contains the following code:
@FormUrlEncoded
@POST("loginByPass/")
fun loginByPassword(@Field("login") login: String,
@Field("password") password: String,
@Field("phone") phone: String) : Observable<AuthResponse>
class API {
companion object {
fun getRetrofitAPI() : IAPI {
val interceptor = HttpLoggingInterceptor()
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
val client = OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.addInterceptor(interceptor)
.addNetworkInterceptor(interceptor)
.build()
val retrofit = Retrofit.Builder()
.baseUrl(SERVER_ADDRESS)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
return retrofit.create(IAPI::class.java)
}
}
}
api.loginByPassword(login, password, "")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe({
Log.w("USER_DB", "CODE: " + it.code)
}, {
this.sayError(it.localizedMessage)
}).dispose()
Answer the question
In order to leave comments, you need to log in
I don’t know anything about Retrofit, but ... I suspect that it dispose()
is clearly superfluous here.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question