title: Exclude some fields from JSON Body in POST request using Retrofit Android
body: <p>I am using Retrofit2 to send and receive requests to my server.</p>
  
  <p>Here are my API interface and Model class.</p>
  
  <ol>
  <li><p>Interface</p>
  
  <pre><code>public interface ApiInterface {
  
     @POST("/users/")
     Call&lt;User&gt; signUp(@Body User user);
  
     @POST("/login_url/")
     Call&lt;User&gt; login(@Body User user);
  }
  </code></pre></li>
  <li><p>Retrofit client</p>
  
  <pre><code>public class RetrofitClient {
  
     private static Retrofit retrofit = null;
  
     public static Retrofit getRestClient(String baseUrl) {
         if (retrofit == null) {
             retrofit = new Retrofit.Builder().baseUrl(baseUrl)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
         }
         return retrofit;
     }
  }
  </code></pre></li>
  <li><p>POJO class</p>
  
  <pre><code>public class User {
  
      @SerializedName("id")
      private Integer id;
  
      @SerializedName("email")
      @Expose
      private String email;
  
      @SerializedName("first_name")
      private String firstName;
  
      @SerializedName("last_name")
      private String lastName;
  
      @SerializedName("password")
      @Expose
      private String password;
  }
  </code></pre></li>
  </ol>
  
  <p>I have exposed email and password so that in login request these 2 parameters will be added.
  But for another request like Sign up, I required a first name and last name also to be sent along with email and password.</p>
  
  <p>Can I use same "User" class for both ? because if I expose the first name and last name then, those fields will be also sent in login request.</p>
  
  <p>Is there any other way or should I make different POJO classes for both request ?</p>