I am writing and android add and using retrofit2 to send data to the server.
I am trying to exclude one field from the the object that is being serialized and sent to the server.
The object is named "Cheer" and I try to exclude the field id from it when being sent to the server. iv'e tried using @Expose(false, false) and explained here and tried to make the field private, but it is still sent to the server. See the api, object and call below. Please note, it workes, the object is added to the server, the only issue is that, id is still sent in the JSON and I need to exclude it from it.
Thanks!!!
public class Cheer {
@Expose(deserialize = false, serialize = false)
private int id;
}
public interface CheersAPI {
String BASE_URL = "url:port";
@POST("/cheers")
Call<Cheer> AddCheer(@Body Cheer cheer);
}
cheersAPI.AddCheer(cheerToAdd).enqueue(new Callback<Cheer>(){
@Override
public void onResponse(Call<Cheer> call, Response<Cheer> response) {
Log.d("in the on response", "done creating a cheer");
}
@Override
public void onFailure(Call<Cheer> call, Throwable t) {
Log.d("failed", "failed to add a cheer here!");
}
});