Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server 415 Response code

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?

like image 233
Michael A Avatar asked Jan 02 '12 10:01

Michael A


People also ask

How do I fix error code 415?

Fixing 415 Unsupported Media Type errorsEnsure that you are sending the proper Content-Type header value. Verify that your server is able to process the value defined in the Content-Type header. Check the Accept header to verify what the server is actually willing to process.

What does unsupported media type mean in Postman?

Http 415 Media Unsupported is responded back only when the content type header you are providing is not supported by the application. With POSTMAN, the Content-type header you are sending is Content type 'multipart/form-data not application/json .

How do I change media type in Postman?

To do this, open Postman and create a new request by selecting New->Request from the top left: Under Headers, select Key = Content-Type: For Value, select application/json: THANKS FOR READING.


1 Answers

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.

like image 193
Tarlog Avatar answered Sep 28 '22 05:09

Tarlog