Service methods cannot return void. retrofit

Solution 1:

There is difference in Asynchronous in Retrofit 1.9 and 2.0

/* Synchronous in Retrofit 1.9 */

public interface APIService {

@POST("/list")
Repo loadRepo();

}

/* Asynchronous in Retrofit 1.9 */

public interface APIService {

@POST("/list")
void loadRepo(Callback<Repo> cb);

}

But on Retrofit 2.0, it is far more simple since you can declare with only just a single pattern

/* Retrofit 2.0 */

public interface APIService {

@POST("/list")
Call<Repo> loadRepo();

}

// Synchronous Call in Retrofit 2.0

Call<Repo> call = service.loadRepo();
Repo repo = call.execute();

// Asynchronous Call in Retrofit 2.0

Call<Repo> call = service.loadRepo();
call.enqueue(new Callback<Repo>() {
@Override
public void onResponse(Response<Repo> response) {

   Log.d("CallBack", " response is " + response);
}

@Override
public void onFailure(Throwable t) {

  Log.d("CallBack", " Throwable is " +t);
}
});

Solution 2:

You can always do:

@POST("/endpoint")
Call<Void> postSomething();

EDIT:

If you are using RxJava, since 1.1.1 you can use Completable class.