Add an array as request parameter with Retrofit 2

后端 未结 7 711
故里飘歌
故里飘歌 2020-12-10 11:04

I\'m looking for way to add an int array (e.g [0,1,3,5]) as parameter in a GET request with retrofit 2. Then, the generated url should be like this : http:/

相关标签:
7条回答
  • 2020-12-10 12:04

    Well this did the trick for me

    Step 1 :

    In StateServce.kt

    @GET("states/v1")
    fun getStatesByCoordinates(@Query("coordinates", encoded = true) coordinates: String) : Call<ApiResponse<List<State>>>
    

    Step 2

    While calling from repository

    val mCoordinate : List<Double> = [22.333, 22.22]
    mStateService?.getStatesByCoordinates(mCoordinate.toString().replace(" ", ""))!!
    
    0 讨论(0)
提交回复
热议问题