title: Sending JSON in POST request with Retrofit2
body: <p>I'm using Retrofit to integrate my Web services and I do not understand how to send a JSON object to the server using a POST request. I'm currently stuck, here is my code:</p>
  
  <h2>Activity:-</h2>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      Retrofit retrofit = new Retrofit.Builder().baseUrl(url).
              addConverterFactory(GsonConverterFactory.create()).build();
  
      PostInterface service = retrofit.create(PostInterface.class);
  
      JSONObject jsonObject = new JSONObject();
      try {
          jsonObject.put("email", "device3@gmail.com");
          jsonObject.put("password", "1234");
      } catch (JSONException e) {
          e.printStackTrace();
      }
      final String result = jsonObject.toString();
  
  }
  </code></pre>
  
  <h2>PostInterface:-</h2>
  
  <pre><code>public interface PostInterface {
  
      @POST("User/DoctorLogin")
      Call&lt;String&gt; getStringScalar(@Body String body);
  }
  </code></pre>
  
  <h2>Request JSON:-</h2>
  
  <pre><code>{
  "email":"device3@gmail.com",
  "password":"1234"
  }
  </code></pre>
  
  <h2>Response JSON:-</h2>
  
  <pre><code>{
    "error": false,
    "message": "User Login Successfully",
    "doctorid": 42,
    "active": true
  }
  </code></pre>