krsna
krsna

Reputation: 4333

Postman displaying an Error: format not supported by the requested resource

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.

enter image description here

Upvotes: 1

Views: 1992

Answers (1)

alayor
alayor

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

Related Questions