https://kotlinlang.org logo
#ktor
Title
# ktor
a

Ahmad Hassan

04/02/2024, 9:02 AM
hi, is there any content length limit in ktor Android? I'm getting the content length of size 5632 characters in response but Ktor is returning the response of length 4055 Can anyone suggest something please?
a

Aleksei Tirman [JB]

04/02/2024, 9:18 AM
hi, is there any content length limit in ktor Android?
There is no such limit. Can you share the code snippet where you check the response body size?
a

Ahmad Hassan

04/02/2024, 9:22 AM
Well, I'm using ktor client logging and checking the size of the encrypted string from logs which is 4055
@Aleksei Tirman [JB]
a

Aleksei Tirman [JB]

04/02/2024, 12:55 PM
Can you share the code snippet?
a

Ahmad Hassan

04/02/2024, 1:03 PM
found that this is not ktor response issue But serialization problem Can you suggest how to serialize the class if it has Any type? receiving error on Any: Serializer has not been found for type 'Any'. To use context serializer as fallback, explicitly annotate type or property with @Contextua
Copy code
@Serializable
data class NetworkResponse(
    @SerialName("statusCode")
    val statusCode: String? = null,

    @SerialName("statusMessage")
    val statusMessage: String? = null,

    @SerialName("token")
    val token: String? = null,

    @SerialName("verification_token")
    val verificationToken: String? = null,

    @SerialName("data")
    val data: LinkedHashMap<String, Any>? = null,
)
a

Aleksei Tirman [JB]

04/02/2024, 1:04 PM
I suggest looking into the contextual serializers.
a

Ahmad Hassan

04/02/2024, 1:26 PM
thank you for the response Can you share the link for example, using gson with ktor?
a

Aleksei Tirman [JB]

04/02/2024, 1:27 PM
So are you using Gson or kotlinx.serialization library?
a

Ahmad Hassan

04/02/2024, 1:28 PM
Currently using kotlinx.serialization Now want to use Gson, as serialization require additional setup
a

Aleksei Tirman [JB]

04/02/2024, 1:31 PM
Here, you find serialization examples including the Gson usage.
a

Ahmad Hassan

04/03/2024, 7:16 AM
Thank you for the quick response!