I am learning to use apis in android and I am trying to get a list of images from the Dog Ceo api.
I am using the kotlin serialization, coil and retrofit library.
The Json response looks like this (Note: I've shortened the list because it's so long.)
{
"message": [
"https://images.dog.ceo/breeds/hound-afghan/n02088094_1003.jpg",
"https://images.dog.ceo/breeds/hound-afghan/n02088094_10263.jpg",
"https://images.dog.ceo/breeds/hound-afghan/n02088094_10715.jpg"
],
"status": "success"
}
My model.
@Serializable
data class Dog(
@SerialName("message")
val image: List<String>,
@SerialName("status")
val status: String
)
My interface with an @GET annotation and the endpoint to get the images with a specific breed.
interface DogsApi {
@GET("hound/images")
suspend fun dogApi(): List<Dog>
}
But when running the app I get the following error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dogimages, PID: 8887
kotlinx.serialization.json.internal.JsonDecodingException: Expected start of the array '[', but had 'EOF' instead at path: $
JSON input: .....reeds\/hound-walker\/n02089867_953.jpg"],"status":"success"}
Sorry for the inconvenience, any help is appreciated!
I have tried manipulating the url with @Query or @Path but the result is the same.