у нас проблема с отправкой почтового запроса с параметрами тела.
JSON выглядит так:
{
"userId": 123456,
"comment": "This is a comment"
}
Мы вызываем бэкэнд со следующим интерфейсом:
interface ServiceDetailsService {
@POST(API_CLOSE_EVENT)
fun closeEvent(@Body data: servicePostData): Call<servicePostData>
}
Мы вызываем функцию с:
fun serviceTaskDone(data: servicePostData) {
val call: Call<servicePostData> = service.closeEvent(data)
call.enqueue(object : Callback<servicePostData> {
override fun onResponse(call: Call<servicePostData>, response: Response<servicePostData>) {
Log.d("Output", response.toString())
}
override fun onFailure(call: Call<servicePostData>, t: Throwable) {
Log.d("Output", t.toString())
}
})
}
И когда мы сейчас выполним наш код, появятся следующие ошибки:
11-15 18:40:23.732 23168-23168/de.conlance.shannonapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.conlance.shannonapp, PID: 23168
java.lang.IllegalArgumentException: Unable to create call adapter for retrofit2.Call<de.conlance.shannonapp.data.model.serviceDetails.Task>
for method ServiceDetailsService.closeEvent
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:755)
at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:240)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:165)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy3.closeEvent(Unknown Source)
at de.conlance.shannonapp.presentation.serviceDetails.ServiceDetailsViewModel.serviceTaskDone(ServiceDetailsViewModel.kt:37)
at de.conlance.shannonapp.presentation.serviceDetails.ServiceDetailsFragment$showAcceptErrorDescDialog$1.onClick(ServiceDetailsFragment.kt:171)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: kotlin.TypeCastException: null cannot be cast to non-null type retrofit2.CallAdapter<kotlin.Any, kotlin.Any>
at de.conlance.shannonapp.rx.RetrofitRxErrorHandlingCallAdapterFactory.get(RetrofitRxErrorHandlingCallAdapterFactory.kt:41)
at retrofit2.Retrofit.nextCallAdapter(Retrofit.java:221)
at retrofit2.Retrofit.callAdapter(Retrofit.java:205)
at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:238)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:165)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy3.closeEvent(Unknown Source)
at de.conlance.shannonapp.presentation.serviceDetails.ServiceDetailsViewModel.serviceTaskDone(ServiceDetailsViewModel.kt:37)
at de.conlance.shannonapp.presentation.serviceDetails.ServiceDetailsFragment$showAcceptErrorDescDialog$1.onClick(ServiceDetailsFragment.kt:171)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Мы проверили параметр Void в вызове, и мы также получаем то же сообщение об ошибке, что и ниже.
За любые предложения мы очень благодарны.
С наилучшими пожеланиями