Can I use POST method to get data from the server and GET method to post data to the server?
- 124,154
- 35
- 280
- 359
- 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 Answers
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:
The
GETmethod requests transfer of a current selected representation for the target resource.GETis 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 aGETrequest.[...]
A payload within a
GETrequest 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
GETrequest is cacheable; [...]
The
POSTmethod requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics. For example,POSTis 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
POSTrequests are only cacheable when they include explicit freshness information. However,POSTcaching is not widely implemented.
- 1
- 1
- 124,154
- 35
- 280
- 359