Android Retrofit2 unable to get POST request working

  android, java, retrofit, retrofit2

I’m unable to get POST http request to work. It seems like I’m not using retrofit2 library correctly, but from my research what I have should be working.

This is what my simplified object Class looks like:

public class Tournament {
    private String name;
    private int nOfGames;
    private String game;
    private String userId;

    public Tournament(String name, int nOfGames, String game, String userId) { = name;
        this.nOfGames = nOfGames; = game;
        this.userId = userId;

I tried two approaches:

approach 1:

retrofit interface:

@Headers({"Content-Type: application/json;charset=UTF-8"})
Single<Tournament> createTournament(@Body Tournament tournament);


Tournament tournament = new Tournament(
        "some name",
        "some game",


approach 2:

retrofit interface:

public void insertTournament(
        @Field("Name") String name,
        @Field("NOfGames")  int nOfGames,
        @Field("Game") String game,
        @Field("UserId") String userId,
        Callback<Response> callback);


        new Callback<Response>() {
            public void onResponse(Call<Response> call, Response<Response> response) {
                String output = call.toString();
                String responze = response.toString();

            public void onFailure(Call<Response> call, Throwable t) {
                String output = call.toString();

First approach doesn’t do anything at all, no errors, nothing. I even tried using HttpLoggingInterceptor but nothing shows up at all. No requests are made it seems. Second approach crashes my app entirely because I get No Retrofit annotation found. (parameter #1) error but I’ve seen other post same snippets without any annotation on callback that were supposedly working.

I also use retrofit2 for get requests which are working just fine, it’s just post requests that I’m not able to get working.

Finally here is what works flawlessly (inserts entry into database) if I use it with Postman:

    "Name": "blabla_tournament",
    "NOfGames": 3,
    "Game": "some_game",
    "UserId": "5"

I would suspect it’s something to do with localhost but since get requests are working just like they should be I’m pretty confident the issue is I’m using retrofit2 wrong.

Source: Android Questions