Activity › Forums › Salesforce® Discussions › What is the difference between HTTP Post and HTTP GET in Salesforce apex?
Tagged: HTTP GET, HTTP POST, Salesforce Apex Code, Salesforce Methods
-
What is the difference between HTTP Post and HTTP GET in Salesforce apex?
Posted by Anurag algoworks on July 5, 2018 at 1:47 PMWhat is the difference between HTTP Post and HTTP GET in Salesforce apex?
shariq replied 7 years, 7 months ago 6 Members · 5 Replies -
5 Replies
-
Hello Anurag,
GET- In an HTTP GET request, key/value pairs are specified in the URL
GET requests can be cached
GET requests remain in the browser history
GET requests can be bookmarked
GET requests should never be used when dealing with sensitive data
GET requests have length restrictions
GET requests should be used only to retrieve dataPOST – HTTP POST data is not visible in the URL, and when submitting data to a website.
POST requests are never cached
POST requests do not remain in the browser history
POST requests cannot be bookmarked
POST requests have no restrictions on data length - [adinserter block='9']
-
Hi Anurag,
The GET method is meant for data retrieval only and should not have any side-effects. But POST is meant for that specific purpose: altering data on the server side.
GET requests can easily be forged (see Cross-Site Request Forgery) by just placing an image on a page while forging POST requests is not that easy (this is also a reason why you should only allow authorized POST requests).
Thanks.
-
hi
HTTP POST:
POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource. The POST method is not idempotent, however POST responses are cacheable so long as the server sets the appropriate Cache-Control and Expires headers.
GET requests can easily be forged (see Cross-Site Request Forgery) by just placing an image on a page while forging POST requests is not that easy (this is also a reason why you should only allow authorized POST requests).
-
Hello Anurag,
In both POST and GET you can use parameters in URL.
The one major and simple difference I will say is the payload (Data/records etc as JSON) which can be passed as a response body in POST where as in GET it is not allowedThanks.
-
Hi,
HTTP GET:
GET is idempotent: it is for obtaining a resource, without changing anything on the server. As a consequence it should be perfectly safe to resubmit a GET request.
HTTP POST:
POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource. The POST method is not idempotent, however POST responses are cacheable so long as the server sets the appropriate Cache-Control and Expires headers.
The official HTTP RFC specifies POST to be:
Annotation of existing resources;
Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;
Providing a block of data, such as the result of submitting a form, to a data-handling process;
Extending a database through an append operation.Thanks
Log In to reply.