Retrofit2和kotlin
我试图把Kotlin RxJava和retrofit2结合起来。
@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
注释,只需要替换它,你应该被设置。
在提交多部分表单数据而不是修改URL时,应该使用@Part
,如错误描述。