title: Making a minimal post request with retrofit
body: <p>I am trying to learn about Retrofit since it seems to take care of a lot of the issues I am currently having with JSON requests and handling.</p>
  
  <p>first and foremost, I understand that the methods we use are defined inside of interfaces, while making simple requests to obtain data it is quite simple to specify what is to be retrieved from the url as well as all the necessary endpoints based on the famous github example.</p>
  
  <p>So if we are retrieving information form the github api, we would first create all the necessary pojo models and such and then define the interface as:</p>
  
  <pre><code>public interface GithubService {
      @GET("users/{username}")
      Observable&lt;Github&gt;getGithHubUser(@Path("username")String userName);
  }
  </code></pre>
  
  <p>From that on the main activity we would have something like:</p>
  
  <pre><code>Retrofit retrofit = new Retrofit.Builder()
                  .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                  .addConverterFactory(GsonConverterFactory.create())
                  .baseUrl("https://api.github.com/")
                  .build();
  
          GithubService githubService = retrofit.create(GithubService.class);
          Observable&lt;Github&gt; githubUser = githubService.getGithHubUser("usersName");
          githubUser.subscribeOn(Schedulers.newThread())
                  .observeOn(AndroidSchedulers.mainThread())
                  .map(user -&gt; "Github Username: " + user.getName() + "\nUrl:" +user.getUrl() + "\nfollowing: "+ user.getHireable())
                  .subscribe(userInfo -&gt; Log.d("Output", userInfo));
  </code></pre>
  
  <p>My question here would be how to send JSON information if the url requires something like this:</p>
  
  <pre><code>"data={\"process\":\"procesNumber\", \"phone\":\"123456\"}"
  </code></pre>
  
  <p>Basically, in order to get any response form the server I have been doing this using simple okhttp:</p>
  
  <pre><code>OkHttpClient client = new OkHttpClient();
          RequestBody body = RequestBody.create(CREATE_MEDIA_TYPE, "data={\"process\":\"procesNumber\", \"phone\":\"123456\"}");
          String ALLWAYS_API = "http://something something bla bla";
          Request request = new Request.Builder()
                  .url("https://blablabla")
                  .post(body)
                  .build();
  
          Call call = client.newCall(request);
          call.enqueue(new Callback() {
              @Override
              public void onFailure(Call call, IOException e) {
                      ... etc etc etc
              }   
  </code></pre>
  
  <p>To my understanding, even I need to create a pojo class that represents the data that needs to be sent to retrofit, something along the lines of:</p>
  
  <pre><code>public class DataRequest {
      final String proces;
      final String phone;
  
      DataRequest(String process, String phone) {
          this.process = process;
          this.phone = phone;
  
      }
  }
  </code></pre>
  
  <p>Which would comply to the information being sent to the request, but how would I actually parse that to the interface implementation?</p>
  
  <pre><code>interface DataService {
      @Post(not a clue what to place here)
      DataRequest postJson(@Body how?)
  
  }
  </code></pre>
  
  <p>And how would I actually add that to the retrofit builder? The examples that I am using come from different forums on the web as well as other questions asked by other users, this one in particular helped a lot in understanding a couple of things: <a href="https://stackoverflow.com/questions/21398598/how-to-post-raw-whole-json-in-the-body-of-a-retrofit-request">How to POST raw whole JSON in the body of a Retrofit request?</a> but I still don't understand where everything goes and some of the other questions and examples are far too complex for what I need to do. </p>