Reputation: 4333
I was trying my first demo program in Restful APIs using JAX-RS.
I'm using Postman as my REST client. I tried this piece of code which should display hello world
in my REST client. Instead, I got an error as shown below:
InjectDemo
class:
@Path("/injectdemo")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public class InjectDemo {
@GET
@Path("/annotations")
public String getParametersUsingAnnotation(){
return "hello world";
}
}
I'm getting this error in my Postman REST client. Note that, I placed the class files in the correct directory only.
Upvotes: 1
Views: 1992
Reputation: 5035
You should add Accept=text/plain
and Content-Type=text/plain
Headers in postman
.
Or you should set the value of those Headers in your @Produces
annotation.
Upvotes: 1