3
我试着将Kotlin RxJava和retrofit2结合起来。Retrofit2和kotlin
@GET("/xxxxxxxxxxxx/{id}.json")
fun getHotel(@Part("id") id : String) : Observable<Response<Hotel>>
当我尝试调用此方法(getHotels()):
var subscription = HotelsFactory.getHotelService((activity.applicationContext as App)
.client)
.getHotel(arguments.getInt("id").toString())
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({response -> showHotels(response)})
{throwable -> throwable.printStackTrace()}
mSubscription.add(subscription)
我借此之一:
@part参数只能与多部分编码时使用。
您应该使用'@ Path'而不是'@ Part' – jturolla