I am using a JAX-RS web application with Jersey and Tomcat. Get requests are fine however when I try to post JSON I get an HTTP status 415 - Unsupported Media Type.
Here is my simple HelloWorld.java:
package service;
import javax.ws.rs.*;
@Path("hello")
public class HelloWorld {
@GET
@Produces("text/plain")
public String get() {
return "hello world";
}
@POST
@Consumes("application/json")
public String post(JS input) {
return input.hello;
}
public static class JS {
public String hello;
}
}
Here is the request I try in Postman (with 'application/json' header):
Here is the project layout with libraries:
I am using:
- Java 7 x64
- Jersey 2.17
- Tomcat 7.0.62 x64
Thanks!
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…