I am new to REST and web services. I am trying to add two numbers with the below code.
import javax.ws.rs.GET;import javax.ws.rs.POST;import javax.ws.rs.Path;import javax.ws.rs.PathParam;import javax.ws.rs.Produces;import javax.ws.rs.core.MediaType;@Path("/calc")public class CalcREST { /*@GET @Path("/add/{a}/{b}") @Produces(MediaType.TEXT_PLAIN) public String addPlainTextPost(@PathParam("a") double a, @PathParam("b") double b) { return (a + b) +""; }*/ @POST @Path("/add/{a}/{b}") @Produces(MediaType.TEXT_PLAIN) public String addPlainTextPost(@PathParam("a") double a, @PathParam("b") double b) { return addPlainText(a,b); } public String addPlainText(double a, double b) { return (a + b) +""; } }
I am trying to test using both GET and POST. For both GET and POST I am invoking the APIs ashttp://:9999/calcrest/calc/add/1/5
For Get I get the results properly. However If i comment out GET and keep POST, I am not able to get any results, just blank.
Any help would be appreciated.