mehrandvd
mehrandvd

Reputation: 9116

Is it true that POST can be used instead of GET in all scenarios?

I've read lots of articles about the differences between GET and POST. Lots of them are available here at StackOverflow.

A summary of the important differences is:

Concluding this summary, Using GET in POST situations is bad and dangerous. But is it true that ignoring the easiness, POST can be used as a replacement of the GET requests as it seems it totally covers the GET requirements.

To clarify that I'm not crazy!, I'm not going to use POST instead of GET. This question is just about to check if I understand the GET and POST difference correctly.

Upvotes: 2

Views: 255

Answers (2)

Francis
Francis

Reputation: 692

Its a good practice that you classify your transaction. These methods are very important specially when you are developing an API Service Oriented architecture or even Single Page Applications.

GET - used to retrieve a dataset. (also has a limitation for url length. parameters are exposed and urlencoded.) POST - Saving/adding (this is more secure)

EX:

GET /items - means you are getting the list of items. 
POST /items - means you are saving/adding item(s)

and later you might need to learn PUT and DELETE too.

But for now, always use POST in your form or ajax request when saving/adding data. and GET when retrieving data.

Upvotes: 0

Erwin Bolwidt
Erwin Bolwidt

Reputation: 31279

No, POST is not a replacement of GET requests. There are two important things that a POST request cannot do that a GET request can.

  1. You cannot generate a POST request simply by typing a URL in the address bar of the browser. This always generates a GET request.
  2. You cannot generate a POST requesting using an ordinary link in HTML. This has far-reaching consequences. You cannot find a page that is only accessible using a POST request with any search engine, and you cannot link to it unless it is done by an HTML form or using Javascript.

Upvotes: 3

Related Questions