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
            Asked
            
        
        
            Active
            
        
            Viewed 636 times
        
    0
            
            
         
    
    
        Avinash
        
- 12,851
- 32
- 116
- 186
- 
                    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 Answers
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
        
- 41,901
- 18
- 127
- 145
 
    
    
        Fabricator
        
- 12,722
- 2
- 27
- 40
- 
                    
- 
                    
- 
                    This info might be correct but it doesn't answer the question *Can I use REST HTTP POST to query a database* – Tim Jun 02 '14 at 06:32
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
        
- 4,271
- 4
- 38
- 62