On Android, I initially implemented a Retrofit interface like this:
@DELETE(USER_API_BASE_URL + "/{id}")
public void deleteUser(@Path("id") String id, Callback<User> callback);
The server returns 204 NO CONTENT upon a successful deletion. This was causing the callback to trigger failure, with retrofit.RetrofitError: End of input at character 0 of
, as it was expecting a User
object back with the response.
I then rewrote it like this, using Void
instead of User
:
@DELETE(USER_API_BASE_URL + "/{id}")
public void deleteUser(@Path("id") String id, Callback<Void> callback); <-- VOID
But I am getting the same error from the callback. What is the proper way to fix this? Thank you.
Retrofit 2.x
no longer has a ResponseCallback
as mentioned in the other answer. You want to use a Response<Void>
type.
The RxJava declaration:
@PUT Observable<Response<Void>> foo();
The standard declaration:
@PUT Call<Response<Void>> bar();