I try to pass a parameter via GET to a REST method.
@GET
@Path("{id}")
public Response getUser(@PathParam("id") String id) {
Query qry = em.createQuery("from User c WHERE id = :user_id");
qry.setParameter("user_id", id);
List<User> results = qry.getResultList();
if(results.size() > 0) {
return Response.ok(results.get(0),MediaType.APPLICATION_JSON_TYPE).build();
} else {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
}
If I call it via the Rest Client with:
client = ClientBuilder.newClient();
Response response = client.target(TestPortProvider.generateURL("/user")+"/abc").request().get(Response.class);
then the method gets called but the parameter is empty. If I remove the "abc"
from the GET url the method gets not called. Also if I remove the @Path("{id}")
it doesn't work too. It seems as there is a parameter but it's empty for no reason. Maybe some one can help me to fix the problem.
kind regards
sadly the reason was a wrong import for PathParam. so a big note to my desk ... if unchecked things doesn't work ... check your imports that are generated by your IDE.