Java – Transform POST with custom principal parameter names

Transform POST with custom principal parameter names… here is a solution to the problem.

Transform POST with custom principal parameter names

I’m using an API that takes “private” as a parameter to the principal in some POST operations.

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

The body parameter should look like this

public class PlanParamUpdate {

public boolean private;

}

Apparently this is a reserved word… So, how do I define it to use this object.

Thanks

Solution

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

Related Problems and Solutions