In javascript I am making an ajax post request to one of my JAX-RS functions like this
var postPackingListRequest = $http({
method: "post",
url: "/rest/v1/submit",
data: $scope.items
});
And now in my JAX-RS method I am trying to get the varibale $scope.items
that was passed. I know I can get path params in the path like this
public Response getPathParams(@QueryParam("id") int id) {
But how can I get the data, which is passed in the body?
Thanks
EDIT
@POST
@Path("submit")
@Consumes(MediaType.APPLICATION_JSON)
@ApiResponses({ @ApiResponse(code = 201, response = Response.class) })
@Produces("application/json")
public Response submitPackingList(TestUser testUser) {
}
public class TestUser {
public String id;
public String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
When I send a request to this with the TestUser there I am getting a HTTP 400 error. Here is how I am sending it
var postPackingListRequest = $http({
method: "post",
url: "/rest/v1/submit",
data: "{'user':'1', 'name':james}"
});