I’m developing a REST web service in which I use a ID in the URL to specify a patient, like this:
WS/services/patient/1
Where “1” is the id of the patient. So, in the code, I specified like this:
@GET
@Path("{id}")
public void getPatient(@PathParam("id") int cId) {
...
}
I saw it in one example, but mine is failing. I’m getting this error:
com.sun.jersey.api.container.ContainerException: Method, public void PresentationLayer.PatientResource.getPatient(int), annotated with GET of resource, class PresentationLayer.PatientResource, is not recognized as valid Java method annotated with @HttpMethod.
I don’t know why is doing this. In the example I saw it worked. Any hints?
EDIT: If I dont write the @PathParams(“id”), it works… but then, how can I get the id from the url?
You are trying to service a
GETrequest using a method that returns no response (return typevoid).