0

Can I use REST HTTP POST to query a database, for which I am designing a REST API SERVICE. Basically my confusion is whether to use GET or POST. I want to pass some parameter to the query so I was thinking to use POST. But reading on net I found that GET should be used mainly if there is READ ONLY ACCESS and POST should be used when you create something on the server side

Avinash
  • 12,287
  • 29
  • 107
  • 180
  • possible duplicate of [When do you use POST and when do you use GET?](http://stackoverflow.com/questions/46585/when-do-you-use-post-and-when-do-you-use-get) – Tim Jun 02 '14 at 06:30

2 Answers2

0

You are right. By convention, GET is used to retrieve information, POST for creating, PUT for modifying, and DELETE for deleting. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Tim
  • 39,651
  • 17
  • 123
  • 137
Fabricator
  • 12,556
  • 2
  • 25
  • 39
0

If you want to render information based on identifier then you should get it through GET.

basically CRUD is treated with REST by assigning dedicated http methods which are as follows:

Create => POST

Read => GET

Update => PUT

delete => DELETE

if you using POST for getting Read Only Information there's no harm but You are violating REST principle

Pramod S. Nikam
  • 3,957
  • 4
  • 31
  • 56