3

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:

0

1 Answer 1

3

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 
}
Sign up to request clarification or add additional context in comments.

3 Comments

thnx for answer, I could not find out, @PathVariable annotation in javax.ws package?
@rish I updated my answer. I gave you the Spring approach first
thank you so much, I'll add something here after @PathParam key name should come, like @PathParam("id")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.