I am using Jetty web server, and Jersey for REST handling.
I defined:
@POST
@Path("/sendMessage")
@Consumes ({MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response sendMessage(@Context final UriInfo uriInfo)
{
logger.debug("sendMessage:");
System.out.println("Received POST!");
return Response.status(Response.Status.OK).build();
}
However, when I send a http request, http://localhost:8080/hqsim/sendMessage
, the server returns a 415 code.
It's like the call is not allowed. How can I fix this error?
415 means that the media type is unsupported.
The most likely case is that you are either missing the Content-Type
header in your request, or it's incorrect. In your case it must be application/xml
or text/xml
.