0
Follow
10
View

Exception deserializing Json in Retrofit, "Polymorphic serializer was not found for missing class discriminator ('null')"

echo161 注册会员
2022-11-29 05:43

Try changing the Call interface to Response in the retrofit interface.

@POST("/newCustomer")
suspend fun newCustomer(@Body data : Customer ) :Call<NewCustVals>

to

@POST("/newCustomer")
suspend fun newCustomer(@Body data : Customer ) :Response
daiyuanrui 注册会员
2022-11-29 05:43

Could you change the return type from call to respond and make the necessary changes and check..

"Call" is useful when we are willing to use its enqueue callback function.

When we use Coroutines or RxJava in the project(which is the best professional practice) to provide asynchronous execution , we don't need enqueue callback. We could just use Response.

Since we are not using the callback the polymorphism is not triggered.

github gist for kotlin serialization issue