function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ujwala Mane 17Ujwala Mane 17 

Rest API Get and POST

Hi all,
1) i am learning REST api. I am not getting difference between @httpGet declaration and when we declare like 
 
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
what is difference between these two declaration.??
2) When we write GET method? when we want to send data from salesforce to other system or when we want to get data from other system into salesforce??

 
Nubes Elite Technologies Pvt. LtdNubes Elite Technologies Pvt. Ltd
Hi Ujwala,


1)  HttpRequest req = new HttpRequest();
               
Use the HttpRequest class to programmatically create HTTP requests like GET, POST, PUT, and DELETE. 
               Use the XML classes or JSON classes to parse XML or JSON content in the body of a request created by HttpRequest.
      Http http = new Http();
               
Use this class to initiate an HTTP request and response.


2) 'GET' request is used to get a resource from a server. If you perform a `GET` request, the server looks for the data you requested and sends it back to you. In other words, a `GET` request performs a `READ` operation. This is the default request method.

For more details, I request you to refer to official documentation by SFDC.

Thank You,
www.nubeselite.com
Development | Training | Consulting

Please mark this as solution if your problem is solved.
v varaprasadv varaprasad
Hi,

Please check once below link for more INFO : 
https://www.youtube.com/watch?v=7PaDtgPLH90&t=432s (https://www.youtube.com/watch?v=7PaDtgPLH90&t=432s)

Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.



Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: salesforcestart1@gmail.com

Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1



Thanks,
Email: salesforcestart1@gmail.com