javarestpostjax-rshttp-status-code-415

POST with Jax-RS giving HTTP error code 415?


I have the following POST endpoint that uses jax-rs framework:

    @POST
    @NoCache
    @Path("/{client}/email/template/type/{type}")
    public void sendEmail(
    @PathParam("client") String client,
    @PathParam("type") String communicationTemplateType) {
        emailService.sendEmail(client, communicationTemplateType);
    }

Whenever I am hitting this endpoint I am getting the following error with an error code of 415:

JBWEB000135: The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.

What is the issue with my endpoint?


Solution

  • As reported inside https://docs.oracle.com/cd/E19798-01/821-1841/6nmq2cp22/index.html:

    If a resource is unable to consume the MIME type of a client request, the JAX-RS runtime sends back an HTTP 415 (“Unsupported Media Type”) error.

    Did you try to add a @Consumes notation to specify the accepted media type?