-3

Please anyone give me a clear understanding of why web service with post request cannot be run by putting the url in the browser unlike get method. I tried running the url in the browser for post method,but it didn't display anything.But when i tried it on SoapUI, I got my desired result. Any help would be appreciable.

Pritesh Naik
  • 58
  • 10

2 Answers2

3

Because browser send a GET request and your service is expecting a POST request.

Ricky
  • 155
  • 1
  • 7
0

It is because of the difference in a GET and a POST request. POST requests do not use the url to send data. An easy example to understand why this is the case would be a login. You would certainly not want to send your login password in the url.

Absent
  • 884
  • 3
  • 11
  • 24
  • So then how to send parameters with the post request.A simple example would be enough to clear my doubt.Thanks. – Pritesh Naik Sep 19 '17 at 09:44
  • An example can be found in this answer: [link] (https://stackoverflow.com/a/21657510/8596064) – Absent Sep 19 '17 at 10:39
  • Good example from client side.Thank you.But how to access this parameters in java rest web service? – Pritesh Naik Sep 20 '17 at 04:43
  • If you are using Spring, try @RequestParam. If you are using servlets, maybe these answers can help https://stackoverflow.com/questions/14525982/getting-request-payload-from-post-request-in-java-servlet?rq=1 – Absent Sep 20 '17 at 05:48