I am facing a weird issue while serializing a data class to json in an http request.
Working code:
@Serializable
data class ComanyCustomerLoginData(
val email: String,
val credential: String,
val companyUUID: String,
)
val customerLoginData = ComanyCustomerLoginData("trwla@gmail.com", "1234", "d80f0b72-a062-11eb-bcbc-0242ac130002")
val response = client.post<HttpResponse>(URL) {
contentType(ContentType.Application.Json)
body = customerLoginData
}
Non working code
@Serializable
data class ComanyCustomerLoginData(
val email: String,
val credential: String,
val companyUUID: String = "d80f0b72-a062-11eb-bcbc-0242ac130002",
)
val customerLoginData = ComanyCustomerLoginData("trwla@gmail.com", "1234")
val response = client.post<HttpResponse>(URL) {
contentType(ContentType.Application.Json)
body = customerLoginData
}
In the non working code, in data class constructor there is one default parameter but when its serialized I don't see companyUUID in that json but working code creates a key named companyUUID.
can you please point out what is the issue?