3

I'm try to combine Kotlin RxJava and retrofit2.

@GET("/xxxxxxxxxxxx/{id}.json")
fun getHotel(@Part("id") id : String) : Observable<Response<Hotel>>

When I try to call this method (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)

I take this one:

@Part parameters can only be used with multipart encoding.

Illya Bublyk
  • 712
  • 6
  • 21

1 Answers1

5

The problem is you're trying to use the @Part annotation where you should be using the @Path annotation, just replace it and you should be all set.

@Part, as the error describes, should be used when submitting multipart form data not for modifying the URL.

Bobbake4
  • 24,509
  • 9
  • 59
  • 94