I have a class looking like this:
public class Test {
@JsonProperty("name")
private String name;
public Test(){}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Also there is an endpoint class using javax.ws.rs:
@Path("/Test")
public class Endpoint {
@POST
@Consumes("application/json")
@Produces("application/json")
@HeaderParam("Accept") @DefaultValue("application/json")
public Response createTest(String json) {
return Response.status(Response.Status.ACCEPTED).entity(json).build();
}
}
This works as expected.
Question: How can I make createTest() take the "Test" class as a parameter instead of "String"?
Trial: Sending the following gives "415 Unsupported Media Type" when using "Test" as a paramter to createTest():
POST ../Endpoint/ HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 56d06798-2b32-57fc-c22a-0240aceb8f98
{
"name": "Kalle"
}