Skip to content Skip to sidebar Skip to footer

Rxjava: Unable To Create Call Adapter For Rx.observable Error

What i do: public interface ApiInterface { @Multipart @POST('/android/upload/index.php') Observable postImage(@Part MultipartBody.Part image,

Solution 1:

The problem is in the following part:

Observable<Response>

Response always needs a specified body type. It looks like your response don't have a body, so you should replace it with this:

Observable<Result<Void>>

...and request the response using result.response()

Solution 2:

If the name parameter is only String, I think the api should be called like:

publicinterfaceApiInterface {
    @Multipart@POST("/android/upload/index.php")
        Observable<Response> postImage(@Part MultipartBody.Part image,   @Part("name") String name);
}

Solution 3:

Include call adapter factory, if you forget it.

RxJava2: compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

RxJava : compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'

Edit:

Ok, is because you need to convert multipart, not text, so change will be here:

RequestBodyname= RequestBody.create(MediaType.parse("multipart/form-data"), "upload_test");

Also mediatype should be the same

RequestBodyreqFile= RequestBody.create(MediaType.parse("multipart/form-data"), file);`

For more Informations take a look here.

Post a Comment for "Rxjava: Unable To Create Call Adapter For Rx.observable Error"