skip to Main Content
i tried this :
interface MYAPI {
 @GET("get-languages")
 fun getdata() : Call<List<Data.Language>>
 } 
this is my api service   

{
"message": "success",
"data": {
"language": [ {"id": 5,
"name": "English",
"icon": "19638193-en.png"
},
{
"id": 6,"name": "turkish","icon": "19638199-tr.png"}
] }
}

2

Answers


  1. Chosen as BEST ANSWER

    Solved..

    i add to AndroidManifest :

    android:usesCleartextTraffic="true"
    

  2. {
    
       "message":"success",
    
       "data":{
    
          "language":[]
    
       }
    
    }
    

    Share your response model but you will need the "data" attribute that is a language model. If you use directly the language model then won´t works.

    So a possible data could be:

    data class LanguageResponse(val id: Int, val name: String, val icon: String)
    data class LanguagesResponse(val language: List<LanguageResponse>)
    data class DataLanguageResponse(val data: LanguagesResponse)
    

    And your call:

    interface MYAPI {
     @GET("get-languages")
     fun getdata() : Call<DataLanguageResponse>
    } 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search