Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java REST call using angularjs with param value

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:

like image 696
deen Avatar asked Nov 22 '25 09:11

deen


1 Answers

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 
}
like image 123
xenteros Avatar answered Nov 23 '25 23:11

xenteros