Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Get and post method in comparision with HTTP and REST

I am new to REST. I want to know when to use get methods and when to use post methods. In the process of my literature survey I came across this knowledge.

Actually when I searched for HTTP get and post methods, I read that get doesnt encode URL and post encodes the URL

When I searched for rest get and post methods, I read that get method is used to retrieve data from server and post method is to add some data to server.

But I also read that rest is nothing but a convention to use HTTP.

So I feel like some things are contradicting here. Are the methods of HTTP different?

Please clarify. Also any suggestions on when to use get and post methods are welcome

Resource from which i got this information:

https://www.ibm.com/developerworks/webservices/library/ws-ful/

http://www.cs.tut.fi/~jkorpela/forms/methods.html

like image 436
javaMan Avatar asked Jun 27 '12 15:06

javaMan


People also ask

What is the difference between GET and POST method in REST API?

Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data from client to ...

What is the difference between the HTTP methods GET and POST?

In GET method we can not send large amount of data rather limited data is sent because the request parameter is appended into the URL. In POST method large amount of data can be sent because the request parameter is appended into the body.


1 Answers

GET should be used to retrieve a resource. This operation should be idempotent, meaning it should not change any state on the server.

POST should be used to add new information to the server. This is usually performed on a URL that represents a "container" of resources. The POST will add a new resource to this container.

PUT should be used to update an existing resource.

DELETE should be obvious.

You might enjoy reading this: http://tomayko.com/writings/rest-to-my-wife

like image 62
Steve H. Avatar answered Oct 05 '22 02:10

Steve H.