2

Can I use POST method to get data from the server and GET method to post data to the server?

cassiomolin
  • 124,154
  • 35
  • 280
  • 359
Tung Nguyen
  • 59
  • 1
  • 2
  • 7
  • What platform you are working on, what language – gurmandeep Sep 08 '16 at 08:43
  • A POST request can have a response, but a GET request can't have a body (well technically it can, but there's surprisingly few systems that support it). Therefore this question makes no sense. Please explain what you're trying to do, and read [ask] and share your research. – CodeCaster Sep 08 '16 at 08:45

1 Answers1

2

GET and POST methods exist for different purposes. Their semantic and use are described in the RFC 7231, one of the references for the HTTP/1.1 protocol.

See the quotes below:

4.3.1. GET

The GET method requests transfer of a current selected representation for the target resource. GET is the primary mechanism of information retrieval and the focus of almost all performance optimizations. Hence, when people speak of retrieving some identifiable information via HTTP, they are generally referring to making a GET request.

[...]

A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.

The response to a GET request is cacheable; [...]

4.3.3. POST

The POST method requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics. For example, POST is used for the following functions (among others):

  • Providing a block of data, such as the fields entered into an HTML form, to a data-handling process;

  • Posting a message to a bulletin board, newsgroup, mailing list, blog, or similar group of articles;

  • Creating a new resource that has yet to be identified by the origin server; and

  • Appending data to a resource's existing representation(s).

[...]

Responses to POST requests are only cacheable when they include explicit freshness information. However, POST caching is not widely implemented.

Community
  • 1
  • 1
cassiomolin
  • 124,154
  • 35
  • 280
  • 359