0

I have created a RestfulWeb Service in Java that is working well with GET requests. However I cannot find some good resource on how to make it accept POST requests.

This is how I run GET

@Path("/hello")
public class Hello {

    @GET
    @Path(value = "/ids/{id}")
    public String ids(@PathParam(value = "id") final String id) throws JSONException {
        return getResults("select * from " + id);
    }

In order to access this method from web I just go to mywebservice.com/hello/thisismyID and the method receives the "ID".

How would this look if it was to be done with a POST.

Thanks in advance,

-D

Dite Gashi
  • 128
  • 2
  • 13

2 Answers2

1

Example

@Path("/hello")
public class Hello {

    @POST
    @Path(value = "/ids")
    public String ids(@HeaderParam("id") final String id) throws JSONException {
        return getResults("select * from " + id);
    }
}
MariuszS
  • 27,972
  • 12
  • 103
  • 144
1
@Path("/hello")
public class Hello {

    @POST
    @Path("/ids/{id}")
    public String ids(@PathParam("id") final String id) throws JSONException {
        return getResults("select * from " + id);
    }
}

an exhaustive tutorial can be found here: Vogella_REST

sschrass
  • 6,331
  • 6
  • 39
  • 53