title: How to send JSONObject request in retrofit?
body: <p>I was trying to send JSONObject request (POST method) using retrofit and get the  results as JSONObject, how can i achieve that.? my content type is (application/json)
  Could you share some of your best methods ?</p>
  
  <p>retrofit Interface class</p>
  
  <pre><code>public interface RequestClient {
  @Headers("Content-Type: application/json")
  @POST("TripmakersLowFareShopping")
  Call&lt;FlightResponse&gt;pushRequest(@Body FlightRequest request);  }
  </code></pre>
  
  <p>Request Model Class</p>
  
  <pre><code>public class FlightRequest {
  
  @SerializedName("AgencyID")
  @Expose
  private String agencyID;
  @SerializedName("BranchID")
  @Expose
  private String branchID;
  @SerializedName("OriginDestinationInformations")
  @Expose
  private ArrayList&lt;OriginDestinationInformation&gt; originDestinationInformations = null;
  @SerializedName("PassengerTypeQuantities")
  @Expose
  private ArrayList&lt;PassengerTypeQuantity&gt; passengerTypeQuantities = null;
  @SerializedName("Password")
  @Expose
  private String password;
  @SerializedName("PricingSourceType")
  @Expose
  private Integer pricingSourceType;
  @SerializedName("RequestOptions")
  @Expose
  private Integer requestOptions;
  @SerializedName("SessionId")
  @Expose
  private Object sessionId;
  @SerializedName("SupplierParameterList")
  @Expose
  private ArrayList&lt;SupplierParameterList&gt; supplierParameterList = null;
  @SerializedName("Target")
  @Expose
  private Integer target;
  @SerializedName("TravelPreferences")
  @Expose
  private TravelPreferences travelPreferences;
  @SerializedName("UserName")
  @Expose
  private String userName;
  
  /**
   * No args constructor for use in serialization
   * 
   */
  
  public FlightRequest() {
      super();
      this.agencyID = "20083";
      this.branchID = "10161";
      this.password = "Tj9%2f30XvS59GOBsjHuMd%2bg%3d%3d";
      this.pricingSourceType = 0;
      this.requestOptions = 0;
      this.sessionId = null;
      this.target = 0;
      this.userName = "qc@*****.com";
  }
  
  public String getAgencyID() {
      return agencyID;
  }
  
  public void setAgencyID(String agencyID) {
      this.agencyID = agencyID;
  }
  
  public String getBranchID() {
      return branchID;
  }
  
  public void setBranchID(String branchID) {
      this.branchID = branchID;
  }
  
  public List&lt;OriginDestinationInformation&gt; getOriginDestinationInformations() {
      return originDestinationInformations;
  }
  
  public void setOriginDestinationInformations(ArrayList&lt;OriginDestinationInformation&gt; originDestinationInformations) {
      this.originDestinationInformations = originDestinationInformations;
  }
  
  public List&lt;PassengerTypeQuantity&gt; getPassengerTypeQuantities() {
      return passengerTypeQuantities;
  }
  
  public void setPassengerTypeQuantities(ArrayList&lt;PassengerTypeQuantity&gt; passengerTypeQuantities) {
      this.passengerTypeQuantities = passengerTypeQuantities;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public Integer getPricingSourceType() {
      return pricingSourceType;
  }
  
  public void setPricingSourceType(Integer pricingSourceType) {
      this.pricingSourceType = pricingSourceType;
  }
  
  public Integer getRequestOptions() {
      return requestOptions;
  }
  
  public void setRequestOptions(Integer requestOptions) {
      this.requestOptions = requestOptions;
  }
  
  public Object getSessionId() {
      return sessionId;
  }
  
  public void setSessionId(Object sessionId) {
      this.sessionId = sessionId;
  }
  
  public List&lt;SupplierParameterList&gt; getSupplierParameterList() {
      return supplierParameterList;
  }
  
  public void setSupplierParameterList(ArrayList&lt;SupplierParameterList&gt; supplierParameterList) {
      this.supplierParameterList = supplierParameterList;
  }
  
  public Integer getTarget() {
      return target;
  }
  
  public void setTarget(Integer target) {
      this.target = target;
  }
  
  public TravelPreferences getTravelPreferences() {
      return travelPreferences;
  }
  
  public void setTravelPreferences(TravelPreferences travelPreferences) {
      this.travelPreferences = travelPreferences;
  }
  
  public String getUserName() {
      return userName;
  }
  
  public void setUserName(String userName) {
      this.userName = userName;
  }
  </code></pre>
  
  <p>}
  Response model class</p>
  
  <pre><code>public class FlightResponse {
  
  
  private JSONObject responceData;
  
  
  public JSONObject getResponceData() {
      return responceData;
  }
  
  public void setResponceData(JSONObject responceData) {
      this.responceData = responceData;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Retrofit declaration and functional part</p>
  
  <pre><code>   rqbtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              ArrayList&lt;OriginDestinationInformation&gt; originlist = new ArrayList&lt;&gt;();
              originlist.add(new OriginDestinationInformation(null,"/Date(1503599400000)/",null,"COK","DXB"));
              ArrayList&lt;PassengerTypeQuantity&gt; typeQuantities = new ArrayList&lt;&gt;();
              ArrayList&lt;SupplierParameterList&gt;supplierParameterLists = new ArrayList&lt;SupplierParameterList&gt;();
              supplierParameterLists.add(new SupplierParameterList(false,"EndUserIPAddress","61.0.250.97"));
              supplierParameterLists.add(new SupplierParameterList(false,"EndUserBrowserAgent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"));
              supplierParameterLists.add(new SupplierParameterList(false,null,null));
              supplierParameterLists.add(new SupplierParameterList(false,"UserData","qc@tripmakers.com,971_527564545,Fateh"));
              supplierParameterLists.add(new SupplierParameterList(false,"RequestOrigin","US-localhost"));
  
              typeQuantities.add(new PassengerTypeQuantity(1,1));
              TravelPreferences travelPreferences = new TravelPreferences(1,1);
              FlightRequest request = new FlightRequest();
              request.setOriginDestinationInformations(originlist);
              request.setPassengerTypeQuantities(typeQuantities);
              request.setTravelPreferences(travelPreferences);
              request.setSupplierParameterList(supplierParameterLists);
  
              requestCall(request);
          }
      });
  }
  
  private void requestCall(FlightRequest request) {
       OkHttpClient.Builder httpClient ;
  
      Retrofit.Builder builder = new Retrofit.Builder()
              .baseUrl("http://192.168.1.125:8013/flight/").addConverterFactory(GsonConverterFactory.create());
      Retrofit retrofit = builder.build();
      RequestClient client = retrofit.create(RequestClient.class);
  
      Call&lt;FlightResponse&gt; requestCall = client.pushRequest(request);
      requestCall.enqueue(new Callback&lt;FlightResponse&gt;() {
          @Override
          public void onResponse(Call&lt;FlightResponse&gt; call, Response&lt;FlightResponse&gt; response) {
              Toast.makeText(RetrofitResults.this, "Sucess", Toast.LENGTH_SHORT).show();
          }
  
          @Override
          public void onFailure(Call&lt;FlightResponse&gt; call, Throwable t) {
              Toast.makeText(RetrofitResults.this, "Something went wrong", Toast.LENGTH_SHORT).show();
          }
      });
  }
  </code></pre>