+ Start a Discussion
pooja biswaspooja biswas 

Post Vs Get in apex integration

Hi
Please let me know practical use case differences between POST method and GET method with specific example.
I know that in GET method we can use parameters but not in POST method, but not sure exactly in what scenarrio we need to use.

Thanks
pooja
Best Answer chosen by pooja biswas
Vivek DVivek D
Hi Pooja,

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 allowed
 

All Answers

Dario BakDario Bak
Hi Pooja!

This applies to Salesforce and the rest of you web projects. GET parameters are sent in the URL and that's quiet insecure & easy to change. POST parameters are sent in the message and are secured by https. In general terms I'd always go with POST.

A general comparisson: http://www.w3schools.com/tags/ref_httpmethods.asp

If you find this helpful, please mark as best answer! 
Amit Chaudhary 8Amit Chaudhary 8

Please check below post
1) http://amitsalesforce.blogspot.in/2016/04/rest-api-in-salesforce-execute-rest-api.html
2) http://amitsalesforce.blogspot.in/2016/06/rest-explorer-using-workbench-execute.html
3) http://amitsalesforce.blogspot.in/2016/06/insert-update-delete-record-by-rest-api.html

User-added image

1) Create a record
Method :- Post
URL:- /services/data/v36.0/sobjects/Account/
Request Body :- 
{
  "Name" : "Account from Rest API",
  "phone" : "1111111111",
  "website" : "www.salesforce1.com",
  "numberOfEmployees" : "100",
  "industry" : "Banking"
}
User-added image

2) Retrieve a record

Method :- Get
URL:- /services/data/v36.0/sobjects/Account/0019000001hE8af
User-added image

Let us know if this will help you

Thanks
Amit Chaudhary
Vivek DVivek D
Hi Pooja,

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 allowed
 
This was selected as the best answer