У меня есть этот интерфейс API
@FormUrlEncoded
@Headers("Accept: application/json;charset=UTF-8")
@POST("checkout/guest/netspay")
fun getNestPayCheckOut(
@Field("outlet_id") outLetId: String,
@Field("order_type") orderType:String,
@Field("products") products:String,
@Field("pickup_time") pickUpTime:String,
@Field("total_price_tax") totalPrice:String,
@Field("order_note") orderNote:String,
@Field("name") name:String,
@Field("email") email:String,
@Field("phone") phone:String
):Observable<NetsPayCheckOut>
Вот как я выполняю вызов API
fun getNetsPayGuestCheckOut(
outletId:String, orderType:String,
products:String, pickUpTime:String,
name:String,email:String,
phone:String, totalPrice:String,
note:String,
mNetsCheckOut:MutableLiveData<NetsPayCheckOut>,
mErrorLD: MutableLiveData<Error>
){
mTheApiNew.getNestPayCheckOut(
outletId,orderType,
products,pickUpTime,
name,email,
phone,totalPrice,
note
)
.subscribeOn(scheduler)
.observeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<NetsPayCheckOut> {
override fun onComplete() { }
override fun onSubscribe(d: Disposable) { }
override fun onNext(response: NetsPayCheckOut) {
if(response.status!!){
mNetsCheckOut.value= response
} else {
mErrorLD.value= ServerError(response.message!!)
Log.e("checkout","${response.status} and ${response.message}")
}
}
override fun onError(e: Throwable) {
mErrorLD.value= FailureError(e.message!!)
Log.e("checkout","${e.message} and ${e.localizedMessage}")
}
})
}
Звонок почтальона
Заголовок почтальона
NetsPayCheckOut
& NetsPayData
классы:
import com.google.gson.annotations.SerializedName
data class NetsPayCheckOut(
val code: Int? = null,
@SerializedName("data")
val netsPayData: NetsPayData? = null,
val message: String? = null,
val status: Boolean? = null
)
data class NetsPayData(
val secretKey: String? = null,
val txnReq: String? = null,
val keyId: String? = null
)
Но я всегда получаю эту ошибку
com.jakewharton.retrofit2.adapter.rxjava2.HttpException: HTTP 422
Необработанный объект