square/retrofit

Deserialization is not working

sila0319 opened this issue · 2 comments

I am using Retrofit to send requests to the server, and I created this part as an Android module. I have two apps, and when I send a request from one app to the server, I receive the data correctly and can deserialize it. However, when I send a request from the other app, I receive the correct data from the server, but the deserialization does not work, and null values are returned.

Everything, including the Android SDK, build.gradle version, mainfest settings, Java version, and library versions, matches, but one app is not working correctly. Can you help me figure out why this is happening?

//retrofit module api
@get("${LocationRestClient.locationDocumentApiUrl}/list/search")
fun locationDocumentList(
@Header("x-token") token:String?,
@QueryMap findData: Map<String, String>
) : Call

fun onLocationDocumentList(
token: String?,
condition: LocationDocumentSearchCondition,
isSync : Boolean = true,
success : LocationResponseCallback<ResponseResult>,
error: LocationErrorResponseCallback
){
val sendData = condition.toMap()
val call = request.locationDocumentList(token,sendData)
handleCall(
call,
isSync,
success = { result -> success(result) },
error = { code, locationError -> error(code, locationError) }
)
}

//retrofit module dto
data class LocationDefaultListResult(
@SerializedName("result") val result: Int,
@SerializedName("message") val message: String?,
@SerializedName("data") val data: LocationApiListResult?
)
data class LocationApiListResult(
@SerializedName("content") val content : List,
@SerializedName("total") var total : Long = 0,
@SerializedName("totalElements") var totalElements : Long,
@SerializedName("firstResult") var firstResult : Long = 0,
@SerializedName("maxResult") var maxResult : Int = Int.MAX_VALUE,
@SerializedName("serverTime") var serverTime : Date? = null,
)

Please use Stake Overflow for this kind of support.

You haven't included a stacktrace or details about how Retrofit is set up. You should be able to unit test your whole Retrofit stack using MockWebServer to send fake JSON. For general help using Retrofit, please using GitHub discussions or StackOverflow like @Harin-Kaklotar said.