Skip to content

Problem with deserialization in different requests #2999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
citizen-of-makondo opened this issue Apr 28, 2025 · 1 comment
Open

Problem with deserialization in different requests #2999

citizen-of-makondo opened this issue Apr 28, 2025 · 1 comment

Comments

@citizen-of-makondo
Copy link

citizen-of-makondo commented Apr 28, 2025

Describe the bug
I am writing an android application and ktor is a server. I have 2 requests - 1 for verification of the code that comes to the email, the second for the login. The response to both requests is the same. In 1 case, deserialization is successful, in the second case it crashes with an error, as if all fields were skipped (on the left you can see the model that is in android studio, on the right in intellij idea)

Image

Error
io.ktor.serialization.JsonConvertException: Illegal input: Fields [id, token, username, email, rating, language, country, city, books, photoUrl] are required for type with serial name 'model.User', but they were missing at path: $

Environment

  • Kotlin version: [2.1.10]
  • Kotlin platforms: [JVM]
  • Gradle version: [8.6.1]
  • Librart version: [1.8.1]
@sandwwraith
Copy link
Member

I cannot verify the issue without knowing what the input was. Are you sure it is not empty?
Remember that you can read Ktor's response only once. If you need to deserialize it twice, first store it in the string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants