Search code examples
javapostjax-rsendpoints

Invoking @POST in jax-rs Endpoint


I have an jax-rs endpoint as below. I need to post a message to a web page through this endpoint. When I execute the endpoint using a client the method with @GET executes. But the method with @POST does not execute. I need to know when will be the @POST method will execute. What should I do to invoke the @POST method.

 @GET
@Path("/")
@Produces("text/plain")

    public boolean getLoginStatus(@Context HttpServletRequest request) throws URISyntaxException {
return true;
}

 @POST
@Path("/")
public boolean helloPost() {
    return true;
}

Solution

  • You need to invoke a HTTP POST request from your client - be it a programmatic one (e.g. JAX-RS 2.0 client API), a browser or tools like curl etc. I would strongly suggest using Postman client as a chrome browser extension to execute a POST request and test out your REST service