Javier Manzano
Javier Manzano

Reputation: 4821

Retrofit POST with custom body param names

I'm consuming an API which has "private" as a param on the body on some POST action.

@PATCH("/users/{facebookId}/plan/{myPlanId}")
void updatePlan(@Path("facebookId") String facebookId, @Path("myPlanId") Integer myPlanId, @Body PlanParamUpdate param, Callback<Object> callback);

And the body param should be like this

public class PlanParamUpdate {

  public boolean private;

}

Obviously this is a reserved word... So, How can I define this to use this object.

Thanks

Upvotes: 3

Views: 1769

Answers (1)

Dave Morrissey
Dave Morrissey

Reputation: 4411

Rename your field to isPrivate and annotate it with @SerializedName("private") if you're using GSON, or @JsonProperty("private") if you're using Jackson.

Upvotes: 8

Related Questions