error when trying to return an integer as the entity

Viewed 250

I noticed that when I used Response.status(201).entity(id).build, it returns the following error :

Severe: MessageBodyWriter not found for media type=application/json, type=class java.lang.Integer, genericType=class java.lang.Integer.

    @POST
    @Produces({"application/json"})
    public Response createUser(
            @NotNull @FormParam("username") String username,
            @NotNull @FormParam("password") String password,
            @NotNull @FormParam("role") String role) {

        int id = 12;
        return Response.status(201).entity(id).build();

    }
2 Answers
Related