SlideShare a Scribd company logo
REST API
Vivek Deepak
Swayam Arora
Architecture
1. Stateless
2. Code on demand
3. Easy to use
Open End Point
Client Server
Request
Response
Example :-
1. Weather APIs of Yahoo, Google etc.
2. Site URL from SFDC
Authorized End Point
More about REST
1. GET, POST, PUT, DELETE
2. The Force.com REST API supports OAuth 2.0
3. Friendly URLs
4. Mobile Apps
5. Force.com site
6. Web to Anything form
SOAP API REST API
SOAP is a protocol REST is an architectural style
SOAP defines standards to be
strictly followed
REST does not define too much
standards like SOAP
SOAP defines its own security. RESTful web services inherits
security measures from the
underlying transport
XML data format only Plain text, HTML, XML, JSON
Less Popular More Popular
Compression
• Types of Compression
o Response Compression
o Request Compression
• Compression Headers
o Accept-Encoding header.
o Content-Encoding header.
Hands On
Creating REST Service
1. Write an Apex Class with annotation
@RestResource(urlMapping=‘</resourceURL>*')
2. Create one or more methods using below annotaions:-
1. @HttpGet
2. @HttpPost
3. @HttpDelete
4. @HttpPatch
5. @HttpPut
Exposing REST Service
1. For Secured End Points:
Use a Connected App
2. For Open End Points:
Use Salesforce Sites
Calling REST Service
1. Add Server End Point to ‘Remote Site Settings’.
2. Generate Access Token and Instance URL
1. HttpRequest req = new HttpRequest();
2. req.setMethod('GET');
3. req.setEndPoint(endUrl+'/services/oauth2/token');
4. req.setBody('grant_type=password' +
'&client_id=' + consumerKey+
'&client_secret=' + consumerSecret+
'&username=' + EncodingUtil.urlEncode(userName, 'UTF-8') +
'&password=' + EncodingUtil.urlEncode(password, 'UTF-8'));
5. Http http = new Http();
6. HttpResponse res = http.send(req);
Calling REST Service
3. Calling the REST Api using Access Token:
1. HttpRequest req = new HttpRequest();
2. req.setMethod(‘GET');
3. req.setHeader('Content-Type', 'application/json');
4. req.setEndpoint(instanceUrl+'/services/apexrest/SaveCallLog');
5. req.setHeader('Authorization', 'OAuth '+accestoken);
6. Http http = new Http();
7. HttpResponse res = http.send(req);
Thank You!

More Related Content

What's hot (20)

PPTX
Episode 20 - Trigger Frameworks in Salesforce
Jitendra Zaa
 
PPTX
Salesforce Streaming event - PushTopic and Generic Events
Dhanik Sahni
 
PDF
Introduction to the Salesforce Security Model
Salesforce Developers
 
PPTX
Introduction to Apex for Developers
Salesforce Developers
 
PPTX
Salesforce asynchronous apex
Badan Singh Pundeer
 
PPTX
Salesforce Streaming Api
Jayant Jindal
 
PPTX
Salesforce admin training 1
HungPham381
 
PPTX
Lightning web components
Cloud Analogy
 
PDF
REST API and CRUD
Prem Sanil
 
PDF
Microsoft SharePoint
David J Rosenthal
 
PDF
Two-Way Integration with Writable External Objects
Salesforce Developers
 
PPTX
Episode 4 - Introduction to SOQL in Salesforce
Jitendra Zaa
 
PDF
Introduction to Visualforce
Salesforce Developers
 
PPTX
Introduction to Spring Framework
Serhat Can
 
PPTX
Approval Process in Salesforce
CloudTech 
 
PPTX
Salesforce Integration Pattern Overview
Dhanik Sahni
 
PDF
Apex Enterprise Patterns: Building Strong Foundations
Salesforce Developers
 
PDF
5 Best Features of Power BI Tool
Rishabh Software
 
PPTX
Introducing the Salesforce platform
John Stevenson
 
PPTX
Deep dive into Salesforce Connected App
Dhanik Sahni
 
Episode 20 - Trigger Frameworks in Salesforce
Jitendra Zaa
 
Salesforce Streaming event - PushTopic and Generic Events
Dhanik Sahni
 
Introduction to the Salesforce Security Model
Salesforce Developers
 
Introduction to Apex for Developers
Salesforce Developers
 
Salesforce asynchronous apex
Badan Singh Pundeer
 
Salesforce Streaming Api
Jayant Jindal
 
Salesforce admin training 1
HungPham381
 
Lightning web components
Cloud Analogy
 
REST API and CRUD
Prem Sanil
 
Microsoft SharePoint
David J Rosenthal
 
Two-Way Integration with Writable External Objects
Salesforce Developers
 
Episode 4 - Introduction to SOQL in Salesforce
Jitendra Zaa
 
Introduction to Visualforce
Salesforce Developers
 
Introduction to Spring Framework
Serhat Can
 
Approval Process in Salesforce
CloudTech 
 
Salesforce Integration Pattern Overview
Dhanik Sahni
 
Apex Enterprise Patterns: Building Strong Foundations
Salesforce Developers
 
5 Best Features of Power BI Tool
Rishabh Software
 
Introducing the Salesforce platform
John Stevenson
 
Deep dive into Salesforce Connected App
Dhanik Sahni
 

Viewers also liked (17)

PPTX
Using Apex for REST Integration
Salesforce Developers
 
PDF
Btech Certificat
Muhammed Yasir PT
 
PPTX
OAuth
Vijay Naik
 
PPTX
Lightning Developer Week - Bangalore Salesforce Developer Group
Abhilash Kuntar
 
PPTX
Force.com security
Vijay Naik
 
PPTX
Lightning experience (LEX)_Dec meetup
Abhilash Kuntar
 
PDF
DPC-2016-8-10-67-76-Published Paper-July-2016
Ibrahim Abdel-Rahman
 
PPTX
Visagie by Benedicte
Bénedicte de Jong
 
PDF
Published Paper-ATPB-BOE-SEP-DEC-2007-1-103-2007-final
Ibrahim Abdel-Rahman
 
DOCX
Chelan Manufacturing section
Steven Glover
 
PPTX
The Genetic Background of Chemical Communication and Chemosensory Gene Evolut...
Katri Ketola
 
DOCX
Morel industries section
Steven Glover
 
PDF
Research Published Paper-Feb 2016-Morocco-4845
Ibrahim Abdel-Rahman
 
PPTX
The Rise of Internal Audit
Parth Dave
 
PDF
203-JMES-2230-Chakib-Published Paper-April 2016
Ibrahim Abdel-Rahman
 
PDF
264-JMES-2335-Ellouze-Published Paper-May 2016
Ibrahim Abdel-Rahman
 
PDF
Research Published Paper-Feb 2016-Morocco-4845
Ibrahim Abdel-Rahman
 
Using Apex for REST Integration
Salesforce Developers
 
Btech Certificat
Muhammed Yasir PT
 
OAuth
Vijay Naik
 
Lightning Developer Week - Bangalore Salesforce Developer Group
Abhilash Kuntar
 
Force.com security
Vijay Naik
 
Lightning experience (LEX)_Dec meetup
Abhilash Kuntar
 
DPC-2016-8-10-67-76-Published Paper-July-2016
Ibrahim Abdel-Rahman
 
Visagie by Benedicte
Bénedicte de Jong
 
Published Paper-ATPB-BOE-SEP-DEC-2007-1-103-2007-final
Ibrahim Abdel-Rahman
 
Chelan Manufacturing section
Steven Glover
 
The Genetic Background of Chemical Communication and Chemosensory Gene Evolut...
Katri Ketola
 
Morel industries section
Steven Glover
 
Research Published Paper-Feb 2016-Morocco-4845
Ibrahim Abdel-Rahman
 
The Rise of Internal Audit
Parth Dave
 
203-JMES-2230-Chakib-Published Paper-April 2016
Ibrahim Abdel-Rahman
 
264-JMES-2335-Ellouze-Published Paper-May 2016
Ibrahim Abdel-Rahman
 
Research Published Paper-Feb 2016-Morocco-4845
Ibrahim Abdel-Rahman
 
Ad

Similar to REST API in Salesforce (20)

PPTX
Apex REST
Boris Bachovski
 
PPTX
SFDC REST API
Bohdan Dovhań
 
PPTX
REST API
Tofazzal Ahmed
 
PDF
zendframework2 restful
tom_li
 
PPTX
REST API.pptx WEUEBHEBCWUQBCBEBUEQBBVDHVBQHF BVUQ
patilsudeepmcaamcec2
 
PPTX
Representation_state_transfer_REST API.pptx
patilsudeepmcaamcec2
 
PPTX
Rest & RESTful WebServices
Prateek Tandon
 
PPTX
Apitesting.pptx
NamanVerma88
 
PDF
Designing Usable APIs featuring Forrester Research, Inc.
CA API Management
 
PDF
Build REST APIs like a Jedi with Symfony2
Almog Baku
 
PDF
IRJET- Rest API for E-Commerce Site
IRJET Journal
 
PDF
APIs explained for product managers
Richard Holmes
 
PPTX
REST-API's for architects and managers
Patrick Savalle
 
PPTX
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
PDF
A2 from soap to rest
Arnaud Bouchez
 
PPTX
Introduction To REST
rainynovember12
 
PDF
API Basics
Ritul Chaudhary
 
PPTX
Beginner's Guide REST Basics - 101 by Smartbear
Eski2
 
PPTX
Nom Nom: Consuming REST APIs
Tessa Mero
 
Apex REST
Boris Bachovski
 
SFDC REST API
Bohdan Dovhań
 
REST API
Tofazzal Ahmed
 
zendframework2 restful
tom_li
 
REST API.pptx WEUEBHEBCWUQBCBEBUEQBBVDHVBQHF BVUQ
patilsudeepmcaamcec2
 
Representation_state_transfer_REST API.pptx
patilsudeepmcaamcec2
 
Rest & RESTful WebServices
Prateek Tandon
 
Apitesting.pptx
NamanVerma88
 
Designing Usable APIs featuring Forrester Research, Inc.
CA API Management
 
Build REST APIs like a Jedi with Symfony2
Almog Baku
 
IRJET- Rest API for E-Commerce Site
IRJET Journal
 
APIs explained for product managers
Richard Holmes
 
REST-API's for architects and managers
Patrick Savalle
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
A2 from soap to rest
Arnaud Bouchez
 
Introduction To REST
rainynovember12
 
API Basics
Ritul Chaudhary
 
Beginner's Guide REST Basics - 101 by Smartbear
Eski2
 
Nom Nom: Consuming REST APIs
Tessa Mero
 
Ad

Recently uploaded (20)

PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 

REST API in Salesforce

  • 2. Architecture 1. Stateless 2. Code on demand 3. Easy to use
  • 3. Open End Point Client Server Request Response Example :- 1. Weather APIs of Yahoo, Google etc. 2. Site URL from SFDC
  • 5. More about REST 1. GET, POST, PUT, DELETE 2. The Force.com REST API supports OAuth 2.0 3. Friendly URLs 4. Mobile Apps 5. Force.com site 6. Web to Anything form
  • 6. SOAP API REST API SOAP is a protocol REST is an architectural style SOAP defines standards to be strictly followed REST does not define too much standards like SOAP SOAP defines its own security. RESTful web services inherits security measures from the underlying transport XML data format only Plain text, HTML, XML, JSON Less Popular More Popular
  • 7. Compression • Types of Compression o Response Compression o Request Compression • Compression Headers o Accept-Encoding header. o Content-Encoding header.
  • 9. Creating REST Service 1. Write an Apex Class with annotation @RestResource(urlMapping=‘</resourceURL>*') 2. Create one or more methods using below annotaions:- 1. @HttpGet 2. @HttpPost 3. @HttpDelete 4. @HttpPatch 5. @HttpPut
  • 10. Exposing REST Service 1. For Secured End Points: Use a Connected App 2. For Open End Points: Use Salesforce Sites
  • 11. Calling REST Service 1. Add Server End Point to ‘Remote Site Settings’. 2. Generate Access Token and Instance URL 1. HttpRequest req = new HttpRequest(); 2. req.setMethod('GET'); 3. req.setEndPoint(endUrl+'/services/oauth2/token'); 4. req.setBody('grant_type=password' + '&client_id=' + consumerKey+ '&client_secret=' + consumerSecret+ '&username=' + EncodingUtil.urlEncode(userName, 'UTF-8') + '&password=' + EncodingUtil.urlEncode(password, 'UTF-8')); 5. Http http = new Http(); 6. HttpResponse res = http.send(req);
  • 12. Calling REST Service 3. Calling the REST Api using Access Token: 1. HttpRequest req = new HttpRequest(); 2. req.setMethod(‘GET'); 3. req.setHeader('Content-Type', 'application/json'); 4. req.setEndpoint(instanceUrl+'/services/apexrest/SaveCallLog'); 5. req.setHeader('Authorization', 'OAuth '+accestoken); 6. Http http = new Http(); 7. HttpResponse res = http.send(req);

Editor's Notes

  • #8: Response Compression The REST API can optionally compress responses. Responses are compressed only if the client sends an Accept-Encoding header. The REST API is not required to compress the response even if you have specified Accept-Encoding, but it normally does. If the REST API compresses the response, it also specifies a Content-Encoding header. Request Compression Clients can also compress requests. The REST API decompresses any requests before processing. The client must send a Content-Encoding HTTP header in the request with the name of the appropriate compression algorithm.