I am working on a REST application built with Jackson-2.2.3.
Here is the Dependency:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.2.3</version>
</dependency>
I have a simple endpoint to create a User as below:
@POST
@Path(value = "/addUser")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createUser(User user) {
...
}
As this endpoint consumes JSON, when api users send JSON Jackson will desearilize to User
object.
If user invoke the endpoint with faulty JSON like, missing a property or bad structure. I want to log the fault JSON as a string and ERROR. How can I achieve that?
I tried using Filters but didn't work.