SlideShare a Scribd company logo
Webservices In Salesforce
(Part 2)
Rest Services
Presenter: Suryakanta Mekap, Mindfire Solutions
Date: 24/01/2014
Presenter: Surya Kanta Mekap,
Email: suryam@mindfiresolutions.com
SkypeId: mfsi_suryam
https://www.facebook.com/surya.mekap
Date: Jan 24th 2014
Filemaker Certified Developer
Salesforce Certified Developer

Presenter:Suryakanta Mekap, Mindfire Solutions
Overview
1. Recap
2. REST Webservice
3. Public REST Webservice
3. REST Callout
4. Test classes for webservices
5. Summary

Presenter: Suryakanta Mekap, Mindfire Solutions
Steps for Creation
Step One: Obtain a Salesforce Developer Edition Organization
Step Two: Create class that will work as REST webservice
Step Three: Set Up Authorization
Step Four: Send HTTP Requests

Presenter: Suryakanta Mekap, Mindfire Solutions
REST Webservice
1. First, create and define an Apex class as global with keyword
"@RestResource" to signify the class responsible for handling HTTP
requests and act as REST based web service.
@RestResource(urlMapping='/TestREST/')
global with sharing class HelloWorld {
@HttpGet
global static string sayHelloWorld() {{
return 'Hello';
}
}
The global access modifier declares that the class is visible to all Apex
scripts everywhere.
This means the class can be used by any Apex code, not just the Apex in the
same application.
Presenter: Suryakanta Mekap, Mindfire Solutions
REST Webservice(Continued...)
2. The urlMapping property allows us to set the endpoint(where the
service will be available) .
Example: https://ap1.salesforce.com/services/apexrest/TestREST/
3. @HttpGet, @HttpPost, @HttpDelete, @HttpPut, @HttpPatch keyword
must be included before the methods to respond on a GET, POST ,
DELETE, PUT and PATCH calls respectively.
4. The methods responsible for handling HTTP requests have global access
specifier and static keyword with them.
5. We can use RestRequest object in a method to pass parameters to the
service.
6. The limitation is that you can declare only one method for each
@HttpGet, @HttpPost, @HttpDelete, @HttpPut, @HttpPatch keyword to
respond for each http type request.
Presenter: Suryakanta Mekap, Mindfire Solutions
Oauth 2.0
Salesforce uses authentication to allow users to securely access data
Supported OAuth flows include:

Web server flow, where the server can securely protect the consumer secret.

User-agent flow, used by applications that cannot securely store the consumer
secret.

Username-password flow, where the application has direct access to user
credentials.
After successfully authenticating the user, you’ll receive an access token which can
be used to make authenticated REST API calls.
A remote access/connected app application is an application external to Salesforce
that uses the OAuth protocol to verify both the Salesforce
user and the external application.

Presenter: Suryakanta Mekap, Mindfire Solutions
Oauth 2.0 (Continued...)
OAuth endpoints are the URLs you use to make OAuth authentication
requests to Salesforce.
You need to use the correct Salesforce OAuth endpoint when issuing
authentication requests in your application. The primary OAuth endpoints
are:
For authorization: https://login.salesforce.com/services/oauth2/authorize
For token requests: https://login.salesforce.com/services/oauth2/token
For revoking OAuth tokens:
https://login.salesforce.com/services/oauth2/revoke
All endpoints require secure HTTP (HTTPS).

Presenter: Suryakanta Mekap, Mindfire Solutions
Public REST Webservice
1) Create a REST webservice.
2) Go to Site > Setup > App Setup > Develop > Sites > Select your Site >
Give access of webservice class to site profile.
Lets say this is the location:
https://ap1.salesforce.com/services/apexrest/TestREST/HelloWorld
And our site URL is
https://mindfire-surya-developer-edition.ap1.force.com/
So our final location will be:
https://mindfire-surya-developeredition.ap1.force.com/services/apexrest/TestREST/HelloWorld
Now you can use this location and there will be no need of getting any
access tokens or session Ids.
Presenter: Suryakanta Mekap, Mindfire Solutions
REST Callout
Apex Callouts enable Apex to invoke external web services so that you
connect to third party services.
Before any Apex callout can call an external site, that site must be
registered in the Remote Site Settings page, or the callout fails. 
Salesforce prevents calls to unauthorized network addresses.
Skipping this will result in "System.CalloutException: IO Exception:
Unauthorized endpoint, please check Setup->Security->Remote site
settings. endpoint ="...

Presenter: Suryakanta Mekap, Mindfire Solutions
REST Callout(Continued...)
1. Apex provides several built-in classes(HTTP, HTTPRequest,
HTTPResponse) to work with HTTP services and create HTTP requests like
GET, POST, PUT, and DELETE.
(It also enables the ability to integrate to SOAP-based web services as an
alternate option to leveraging WSDL2Apex. By using the HTTP classes,
instead of WSDL2Apex, the developer has more responsibility to handling
the construction of the SOAP message both for the request and the response.
)
2. Below is a sample example of Restful callout you can make to know the
location of the IP address sent:
Suppose we want to send HTTP GET requests to:
http://www.freegeoip.net/{format}/{ip_or_hostname}
and the supported response format is csv, xml, json.

Presenter: Suryakanta Mekap, Mindfire Solutions
References

http://wiki.developerforce.com/page/Apex_Web_Services_and_Callouts
http://forceguru.blogspot.in/2012/09/creating-public-web-service-in.html
http://blog.deadlypenguin.com/blog/2012/02/03/salesforce-and-soapui/
http://kperisetla.blogspot.in/2012/05/restful-services-on-forcecom-through.html
http://www.fishofprey.com/2011/03/consuming-aspnet-web-service-from.html
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex.htm
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
http://stackoverflow.com/questions/209905/representational-state-transfer-rest-and-simple-object-a
http://www.salesforce.com/us/developer/docs/api_rest/index_Left.html
http://blog.deadlypenguin.com/blog/2012/04/13/salesforce-and-soapui-using-the-default-query-met
http://medbiq.org/std_specs/techguidelines/knowingwhentorest.pdf
http://www.developingthefuture.net/web-services-overview/
http://www.tgerm.com/2010/12/invoking-apex-wsdl-web-services-from.html
http://blogs.developerforce.com/tech-pubs/2011/10/salesforce-apis-what-they-are-when-to-use-them

Presenter: Suryakanta Mekap, Mindfire Solutions
Question and
Answer

Presenter: Suryakanta Mekap, Mindfire Solutions
Thank you

Presenter: Suryakanta Mekap, Mindfire Solutions

More Related Content

What's hot (20)

PPTX
Secure Coding: SSL, SOAP, and REST
Salesforce Developers
 
PPTX
Integrating with salesforce
Mark Adcock
 
PDF
Data Democracy: Use Lightning Connect & Heroku to Visualize any Data, Anywhere
Salesforce Developers
 
PDF
Salesforce API Series: Integrating Applications with Force.com Webinar
Salesforce Developers
 
PPTX
Salesforce Integration Patterns
usolutions
 
PPTX
Exploring the Salesforce REST API
Salesforce Developers
 
PDF
Two-Way Integration with Writable External Objects
Salesforce Developers
 
PPTX
Salesforce CRM Integration Solutions
Atocloud
 
PDF
Lightning Connect Custom Adapters: Connecting Anything with Salesforce
Salesforce Developers
 
PDF
Lightning Out: Components for the Rest of the World
Salesforce Developers
 
PDF
Building a RESTful API on Heroku for Your Force.com App
Salesforce Developers
 
PPTX
Lightning Component - Components, Actions and Events
Durgesh Dhoot
 
PDF
Build Amazing Website without coding using Salesforce SiteForce
vraopolisetti
 
PDF
Secure Salesforce: Common Secure Coding Mistakes
Salesforce Developers
 
PPTX
10 Principles of Apex Testing
Salesforce Developers
 
PPTX
Coding in the App Cloud
Salesforce Developers
 
PPTX
Building apps faster with lightning and winter '17
Salesforce Developers
 
PPTX
Build Consumer-Facing Apps with Heroku Connect
Jeff Douglas
 
PDF
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
PPTX
Migrating Visualforce Pages to Lightning
Salesforce Developers
 
Secure Coding: SSL, SOAP, and REST
Salesforce Developers
 
Integrating with salesforce
Mark Adcock
 
Data Democracy: Use Lightning Connect & Heroku to Visualize any Data, Anywhere
Salesforce Developers
 
Salesforce API Series: Integrating Applications with Force.com Webinar
Salesforce Developers
 
Salesforce Integration Patterns
usolutions
 
Exploring the Salesforce REST API
Salesforce Developers
 
Two-Way Integration with Writable External Objects
Salesforce Developers
 
Salesforce CRM Integration Solutions
Atocloud
 
Lightning Connect Custom Adapters: Connecting Anything with Salesforce
Salesforce Developers
 
Lightning Out: Components for the Rest of the World
Salesforce Developers
 
Building a RESTful API on Heroku for Your Force.com App
Salesforce Developers
 
Lightning Component - Components, Actions and Events
Durgesh Dhoot
 
Build Amazing Website without coding using Salesforce SiteForce
vraopolisetti
 
Secure Salesforce: Common Secure Coding Mistakes
Salesforce Developers
 
10 Principles of Apex Testing
Salesforce Developers
 
Coding in the App Cloud
Salesforce Developers
 
Building apps faster with lightning and winter '17
Salesforce Developers
 
Build Consumer-Facing Apps with Heroku Connect
Jeff Douglas
 
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
Migrating Visualforce Pages to Lightning
Salesforce Developers
 

Viewers also liked (13)

PDF
Webservices in SalesForce (part 1)
Mindfire Solutions
 
PPT
Salesforce REST API
Bohdan Dovhań
 
PPTX
WebServices using salesforce
Rajkattamuri
 
PDF
Integrations with the Force.com Platform Using Custom Apex REST Services
Salesforce Developers
 
PPTX
Using the Tooling API to Generate Apex SOAP Web Service Clients
Daniel Ballinger
 
PPTX
Integrate with External Systems using Apex Callouts
Salesforce Developers
 
POTX
Using the Google SOAP API
Salesforce Developers
 
PPTX
Batchable vs @future vs Queueable
Boris Bachovski
 
PPTX
Apex Testing and Best Practices
Jitendra Zaa
 
PDF
Salesforce API Series: Release Management with the Metadata API webinar
Salesforce Developers
 
PDF
Salesforce Marketing Cloud: Creating 1:1 Journeys
Salesforce Partners
 
PPTX
REST API in Salesforce
Vivek Deepak
 
Webservices in SalesForce (part 1)
Mindfire Solutions
 
Salesforce REST API
Bohdan Dovhań
 
WebServices using salesforce
Rajkattamuri
 
Integrations with the Force.com Platform Using Custom Apex REST Services
Salesforce Developers
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Daniel Ballinger
 
Integrate with External Systems using Apex Callouts
Salesforce Developers
 
Using the Google SOAP API
Salesforce Developers
 
Batchable vs @future vs Queueable
Boris Bachovski
 
Apex Testing and Best Practices
Jitendra Zaa
 
Salesforce API Series: Release Management with the Metadata API webinar
Salesforce Developers
 
Salesforce Marketing Cloud: Creating 1:1 Journeys
Salesforce Partners
 
REST API in Salesforce
Vivek Deepak
 
Ad

Similar to SalesForce WebServices part 2 (20)

DOCX
Salesforce Integration
Er. Prashant Veer Singh
 
PPTX
Salesforce Integration using REST SOAP and HTTP callouts
RAMNARAYAN R
 
PPTX
Rest & RESTful WebServices
Prateek Tandon
 
PDF
Getting Started With Apex REST Services
Salesforce Developers
 
PPTX
Apex REST
Boris Bachovski
 
PPTX
SFDC REST API
Bohdan Dovhań
 
PDF
Exposing Salesforce REST Services Using Swagger
Salesforce Developers
 
PDF
Api apex rest
Vineet Pandya
 
PPTX
SFDC Inbound Integrations
Sujit Kumar
 
PDF
Force.com Integration Using Web Services With .NET & PHP Apps
Salesforce Developers
 
PDF
Building towards a Composite API Framework in Salesforce
Salesforce Developers
 
PPTX
Integration on Force.com Platform
Amit Jain
 
PPT
Designing custom REST and SOAP interfaces on Force.com
Steven Herod
 
PDF
Designing Custom REST and SOAP Interfaces on Force.com
Salesforce Developers
 
PPTX
All Aboard the Boxcar! Going Beyond the Basics of REST
Pat Patterson
 
PDF
Control your world using the Salesforce1 Platform (IoT)
InternetCreations
 
PPTX
Inbound rest web service
David Boukhors
 
PPTX
Episode 11 building & exposing rest api in salesforce v1.0
Jitendra Zaa
 
PDF
REST - What's It All About? (SAP TechEd 2012, CD110)
Sascha Wenninger
 
PDF
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Codemotion
 
Salesforce Integration
Er. Prashant Veer Singh
 
Salesforce Integration using REST SOAP and HTTP callouts
RAMNARAYAN R
 
Rest & RESTful WebServices
Prateek Tandon
 
Getting Started With Apex REST Services
Salesforce Developers
 
Apex REST
Boris Bachovski
 
SFDC REST API
Bohdan Dovhań
 
Exposing Salesforce REST Services Using Swagger
Salesforce Developers
 
Api apex rest
Vineet Pandya
 
SFDC Inbound Integrations
Sujit Kumar
 
Force.com Integration Using Web Services With .NET & PHP Apps
Salesforce Developers
 
Building towards a Composite API Framework in Salesforce
Salesforce Developers
 
Integration on Force.com Platform
Amit Jain
 
Designing custom REST and SOAP interfaces on Force.com
Steven Herod
 
Designing Custom REST and SOAP Interfaces on Force.com
Salesforce Developers
 
All Aboard the Boxcar! Going Beyond the Basics of REST
Pat Patterson
 
Control your world using the Salesforce1 Platform (IoT)
InternetCreations
 
Inbound rest web service
David Boukhors
 
Episode 11 building & exposing rest api in salesforce v1.0
Jitendra Zaa
 
REST - What's It All About? (SAP TechEd 2012, CD110)
Sascha Wenninger
 
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Codemotion
 
Ad

More from Mindfire Solutions (20)

PDF
Physician Search and Review
Mindfire Solutions
 
PDF
diet management app
Mindfire Solutions
 
PDF
Business Technology Solution
Mindfire Solutions
 
PDF
Remote Health Monitoring
Mindfire Solutions
 
PDF
Influencer Marketing Solution
Mindfire Solutions
 
PPT
High Availability of Azure Applications
Mindfire Solutions
 
PPTX
IOT Hands On
Mindfire Solutions
 
PPTX
Glimpse of Loops Vs Set
Mindfire Solutions
 
ODP
Oracle Sql Developer-Getting Started
Mindfire Solutions
 
PPT
Adaptive Layout In iOS 8
Mindfire Solutions
 
PPT
Introduction to Auto-layout : iOS/Mac
Mindfire Solutions
 
PPT
LINQPad - utility Tool
Mindfire Solutions
 
PPT
Get started with watch kit development
Mindfire Solutions
 
PPTX
Swift vs Objective-C
Mindfire Solutions
 
ODP
Material Design in Android
Mindfire Solutions
 
ODP
Introduction to OData
Mindfire Solutions
 
PPT
Ext js Part 2- MVC
Mindfire Solutions
 
PPT
ExtJs Basic Part-1
Mindfire Solutions
 
PPT
Spring Security Introduction
Mindfire Solutions
 
Physician Search and Review
Mindfire Solutions
 
diet management app
Mindfire Solutions
 
Business Technology Solution
Mindfire Solutions
 
Remote Health Monitoring
Mindfire Solutions
 
Influencer Marketing Solution
Mindfire Solutions
 
High Availability of Azure Applications
Mindfire Solutions
 
IOT Hands On
Mindfire Solutions
 
Glimpse of Loops Vs Set
Mindfire Solutions
 
Oracle Sql Developer-Getting Started
Mindfire Solutions
 
Adaptive Layout In iOS 8
Mindfire Solutions
 
Introduction to Auto-layout : iOS/Mac
Mindfire Solutions
 
LINQPad - utility Tool
Mindfire Solutions
 
Get started with watch kit development
Mindfire Solutions
 
Swift vs Objective-C
Mindfire Solutions
 
Material Design in Android
Mindfire Solutions
 
Introduction to OData
Mindfire Solutions
 
Ext js Part 2- MVC
Mindfire Solutions
 
ExtJs Basic Part-1
Mindfire Solutions
 
Spring Security Introduction
Mindfire Solutions
 

Recently uploaded (20)

PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
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
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Digital Circuits, important subject in CS
contactparinay1
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 

SalesForce WebServices part 2