I am trying to make REST call in java using angularjs-
Java Code:-
@GET
@Path("/getData/{id}")
@Produces(MediaType.TEXT_PLAIN)
public static String getData(@PathParam("id") String id) {
//Operation
}
AngularJs REST call-
var response = $http.get('/projName/rest/get/getData', {params: {id: id}});
But it's giving me exception-
org.jboss.resteasy.spi.NotFoundException: Could not find resource for full path:
The error is caused by the fact, that you're trying to access different endpoint. Your endpoint listens for requests like:
projName/rest/get/getData/{id}
//e.g.
projName/rest/get/getData/1
but you're calling:
projName/rest/get/getData?id={id}
projName/rest/get/getData?id=1
Your code should be:
var response = $http.get('/projName/rest/get/getData/' + id);
@GET
@Path("/getData/{id}")
@Produces(MediaType.TEXT_PLAIN)
public static String getData(@PathParam("id") String id) {
//Operation
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With