Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET request can be bookmarked and POST can not . Can anybody explain on this?

Tags:

I am studying the HTTP methods. I read that GET request can be bookmarked and POST request can not be bookmarked. Can anybody explain this with an example?

Thanks

like image 573
giri Avatar asked Feb 01 '10 12:02

giri


People also ask

What is the difference between a GET request and a post request?

POST. HTTP POST requests supply additional data from the client (browser) to the server in the message body. In contrast, GET requests include all required data in the URL.

Can we POST data with GET request?

So, yes, you are allowed to send an entity-body with a HTTP GET request.

What is the difference between GET and POST IN REST API?

1. GET retrieves a representation of the specified resource. POST is for writing data, to be processed to the identified resource.

What is GET request used for?

GET is used to request data from a specified resource. Some notes on GET requests: GET requests can be cached. GET requests remain in the browser history.


2 Answers

An HTTP POST can be bookmarked, but since a bookmark only consists of the URL, all of the form parameters will be lost. This will often mean that the web server doesn't know what to do with the request, since it was expecting some form parameters.

If you submit a form via a GET request, all of the form parameters go into the URL (after the ?), so a bookmark will contain all of the information needed for the webserver to rebuild the page a second time (except for cookies, perhaps, but a webserver is more likely to handle that gracefully)

like image 171
Rob Fonseca-Ensor Avatar answered Oct 25 '22 22:10

Rob Fonseca-Ensor


A POST cannot be bookmarked. Attempting to bookmark a POST will just result in a GET operation on the URL. There's a very good reason for this, GET requests are supposed to be idempotent - that is, making the same GET request numerous times should result in the same response. POST requests on the other hand are not. Allowing POSTs to be bookmarked could result in you paying for something twice, transferring money out of your bank account again, etc.

like image 34
Phill Avatar answered Oct 25 '22 22:10

Phill