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

Tobias Gronbach

02/19/2022, 1:10 PM
I have another issue (hopefully last one). I load a list of quotes from an api. Everything worked fine before migration.
Copy code
override suspend fun getInspiringQuotes(): Resource<List<InspiringQuoteRemote>> {
        return try {
            val quotes = client.get {
                url(WordpressRoutes.InspiringQuotes)
            }.body<List<InspiringQuoteRemote>>()
            Resource.Success(quotes)
        } catch (e: Exception) {
            Timber.e(e)
            Resource.Error(e.localizedMessage)
        }
    }
This is the json-response I receive. I validated the response with an online tool that said it's a VALID (RFC 8259)
Copy code
[
   {
      "quote_author":"Oskar Wilde",
      "quote":"Unzufriedenheit ist der erste Schritt zum Erfolg."
   },
   {
      "quote_author":"Winston Churchill",
      "quote":"Erfolg haben heißt, einmal mehr aufstehen, als man hingefallen ist."
   },
   {
      "quote_author":"Henry Ford",
      "quote":"Erfolg besteht darin, dass man genau die Fähigkeiten hat, die im Moment gefragt sind."
   },

   {
      "quote_author":"Albert Einstein",
      "quote":"Der sicherste Ort für ein Schiff ist der Hafen. Doch dafür sind Schiffe nicht gemacht."
   }
]
Still I get the following error. kotlinx.serialization.json.internal.JsonDecodingException: Expected start of the array '[', but had 'EOF' instead Any idea?
s

Sam

02/19/2022, 1:25 PM
Shot in the dark: maybe you're getting an error response, but it's trying to deserialise it anyway because
expectSuccess
now defaults to
false
?
t

Tobias Gronbach

02/19/2022, 1:48 PM
I get a 200 Ok Response with Content-Type: application/json , so I think that should be fine 🤔
s

Sam

02/19/2022, 1:49 PM
Yeah, sounds like my guess was not correct
t

Tobias Gronbach

02/19/2022, 1:49 PM
Still happy for your thoughts anyway!
a

Aleksei Tirman [JB]

02/19/2022, 4:22 PM
Could you please share an endpoint that is requested in your example if it's a public one?