How to get string response from Retrofit2?

前端 未结 10 1523
时光取名叫无心
时光取名叫无心 2020-12-01 07:44

I am doing android, looking for a way to do a super basic http GET/POST request. I keep getting an error:

java.lang.IllegalArgumentException: Unable to creat         


        
10条回答
  •  生来不讨喜
    2020-12-01 08:04

    I change the Response type, instead of adding ScalarsConverterFactory like this

    interface YourApiService {
    @GET("/endpoint")
        fun getResponse(): Call
    }
    

    And then you can get the string object by

    val str = response.body().toString()

提交回复
热议问题