kostya2394
kostya2394

Reputation: 9

RESTful service doesn't map json into object properly

I have restful service with resource which consumes json, but when i send test request i got empty values in my model object. Here is service:

@Path("bot")
public class BotResource {

    private final Logger log = LogManager.getLogger(BotResource.class);

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public Response update(Json update){
        log.info("test");
        return Response
                .ok()
                .build();
    }
}

Here is model object

import com.fasterxml.jackson.annotation.JsonProperty;
public class Json {
    @JsonProperty("update_id")
    private String Id;

    public Json() {
    }

    public String getId() {
        return Id;
    }

    public void setId(String Id) {
        this.Id = Id;
    }

}

so when i send post request with body {"update_id": 37197384} i have null attribute Id. Glassfish 5 causes no errors about this.

Upvotes: 0

Views: 79

Answers (0)

Related Questions