Salesforce API
 There are many types of APIs like REST API, SOAP API, Bulk API, and Streaming API.
 Together they make up the Salesforce data APIs.
REST API
 REST API is a simple and powerful web service based on RESTful principles.
 REST defines a set of architectural principles by which you can design Web services that focus
on a system's resources, including how resource states are addressed and transferred over
HTTP by a wide range of clients written in different languages.
 REST API supports both XML and JSON.
 Because REST API has a lightweight request and response framework and is easy to use, it’s
great for writing mobile and web apps.
 In layman language, Representational state transfer (REST) or RESTful web services is a way of
providing interoperability between computer systems on the Internet. REST-compliant Web
services allow requesting systems to access and manipulate textual representations of Web
resources using a uniform and predefined set of stateless (In computing, a stateless protocol is
a communications protocol in which no information is retained by either sender or receiver.”
operations.
When to use:
 REST API provides a powerful, convenient, and simple REST-based web services interface for
interacting with Salesforce.
 Its advantages include ease of integration and development, and it’s an excellent choice of
technology for use with mobile applications and web projects.
 However, if you have many records to process, consider using Bulk API, which is based on REST
principles and optimized for large sets of data.
 Apex REST API when you want to expose your Apex classes and methods so that external
applications can access your code through REST architecture.
 Apex REST API supports both OAuth 2.0 and Session ID for authorization.
Bulk API
 Bulk API is a specialized RESTful API for loading and querying lots of data at once.
 By lots, we mean 50,000 records or more.
 Bulk API is asynchronous, meaning that you can submit a request and come back later for the
results.
 There are two versions of Bulk API (1.0 and 2.0). Bulk API 2.0 is easier to use.
 Bulk API is great for performing tasks that involve lots of records, such as loading data into your
org for the first time.
SOAP API
 It stands for Simple Object Access Protocol
 It is a messaging protocol that allows programs that run on disparate operating systems (such as
Windows and Linux) to communicate using Hypertext Transfer Protocol (HTTP) and its Extensible
Markup Language (XML).
 It is a protocol specification for exchanging structured information.
 It uses a Web Services Description Language (WSDL) file to rigorously define the parameters for
accessing data through the API.
 SOAP API supports XML only.
 Most of the SOAP API functionality is also available through REST API.
 Because SOAP API uses the WSDL file as a formal contract between the API and consumer, it’s
great for writing server-to-server integrations.
When to use:
 SOAP API provides a powerful, convenient, and simple SOAP-based web services interface for
interacting with Salesforce.
 You can use SOAP API to create, retrieve, update, or delete records.
 You can also use SOAP API to perform searches and much more.
 Use SOAP API in any language that supports web services.
 Use Apex SOAP API when you want to expose Apex methods as SOAP web service APIs so that
external applications can access your code through SOAP.
 Apex SOAP API supports both OAuth 2.0 and Session ID for authorization.
Streaming API:
 Streaming API is a specialized API for setting up notifications that trigger when changes are
made to your data.
 It uses a publish-subscribe, or pub/sub, model in which users can subscribe to channels that
broadcast certain types of data changes.
 The pub/sub model reduces the number of API requests by eliminating the need for polling.
Streaming API is great for writing apps that would otherwise need to frequently poll for changes.
API Access and Authentication:
 To access Salesforce APIs, you should have API enabled permission and you can integrate.
 All API calls, except for the SOAP API login() call, require authentication.
 You can either use one of the supported OAuth flows or authenticate with a session ID retrieved
from the SOAP API login() call.
API Limits
 There are two types of API limits.
 Concurrent limits cap the number of long-running calls (20 seconds or longer) that are running at
one time.
 Total limits cap the number of calls made within a rolling 24-hour period.
 For a sandbox org, it’s 25 long-running calls and for a Developer Edition org, the limit is five long-
running calls at once.
 There are several ways to check remaining API calls:
1. API Usage box
Setup--- System Overview--- API Usage
Note:
System Overview: give all view like API usage, custom object, Classes etc.
 To setup API Usage Notifications
Setup---- API Usage Notifications
Use REST API
REST Resources and Methods:
 A REST resource is an abstraction of a piece of information or an action, such as a single data
record, a collection of records, or a query.
 Each resource in REST API is identified by a named Uniform Resource Identifier (URI) and is
accessed using standard HTTP methods (HEAD, GET, POST, PATCH, DELETE).
 URI is is a string of characters used to identify a resource.
 REST API is based on the usage of resources, their URIs, and the links between them.
 A REST request consists of four components: a resource URI, an HTTP method, request
headers, and a request body.
 Request headers specify metadata for the request. The request body specifies data for the
request, when necessary.
Note:
Workbench:
 Workbench is a suite of tools for interacting with your Salesforce org through the API.
 URL is https://workbench.developerforce.com/login.php
 Because you can make REST requests from any HTTP sender, there are plenty of other tools
available for you to use (for example, check out cURL or Postman).
Apex REST Callouts
 An Apex callout enables you to tightly integrate your Apex code with an external service.
 The callout makes a call to an external web service or sends an HTTP request from Apex code,
and then receives the response.
 Apex callouts come in two flavors.
1. Web service callouts to SOAP web services use XML, and typically require a WSDL
document for code generation.
2. HTTP callouts to services typically use REST with JSON.
 These two types of callouts are similar in terms of sending a request to a service and receiving a
response.
 But while WSDL-based callouts apply to SOAP Web services, HTTP callouts can be used with
any HTTP service, either SOAP or REST.
Note:
 Whenever possible, use an HTTP service.
 These services are typically easier to interact w ith, require much less code, and utilize easily readable JSON.
Authorize Endpoint Addresses
HTTP and Callout Basics:
 REST callouts are based on HTTP.
 Each callout request is associated with an HTTP method and an endpoint.
 The HTTP method indicates what type of action is desired.
 When the server processes the request, it sends a status code in the response.
 The status code indicates whether the request was processed successfully or whether errors
were encountered.
 If the request is successful, the server sends a status code of 200.
 You’ve probably seen some other status codes, such as 404 for file not found or 500 for an
internal server error.
HTTP classes:
These classes expose the HTTP request and response functionality.
1. Http Class: Use this class to initiate an HTTP request and response.
2. HttpRequest Class: Use this class to programmatically create HTTP requests like GET,
POST, PUT, and DELETE.
3. HttpResponse Class: Use this class to handle the HTTP response returned by HTTP.
 The HttpRequest and HttpResponse classes support the following elements.
a. HttpRequest
 HTTP request types, such as GET, POST, PUT, DELETE, TRACE, CONNECT, HEAD,
and OPTIONS
 Request headers if needed
 Read and connection timeouts
 Redirects if needed
 Content of the message body
b. HttpResponse
 The HTTP status code
 Response headers if needed
 Content of the response body
 This example makes an HTTP GET request to the external server passed to the
getCalloutResponseContents method in the url parameter.
This example also accesses the body of the returned response.
 The previous example runs synchronously, meaning no further processing happens until the
external web service returns a response.
 Alternatively, you can use the @future annotation to make the callout run asynchronously.
Named Credentials as Callout Endpoints:
 A named credential specifies the URL of a callout endpoint and its required authentication
parameters in one definition.
 Salesforce manages all authentication for Apex callouts that specify a named credential as the
callout endpoint so that your code doesn’t have to.
 You can also skip remote site settings, which are otherwise required for callouts to external sites,
for the site defined in the named credential.
 By separating the endpoint URL and authentication from the callout definition, named credentials
make callouts easier to maintain.
 For example, if an endpoint URL changes, you update only the named credential.
 All callouts that reference the named credential simply continue to work.
 If you have multiple orgs, you can create a named credential with the same name but with a
different endpoint URL in each org.
 You can then package and deploy—on all the orgs—one callout definition that references the
shared name of those named credentials.
 If you have multiple orgs, you can create a named credential with the same name but with a
different endpoint URL in each org. You can then package and deploy—on all the orgs—one
callout definition that references the shared name of those named credentials. For example, the
named credential in each org can have a different endpoint URL to accommodate differences in
development and production environments. If an Apex callout specifies the shared name of those
named credentials, the Apex class that defines the callout can be packaged and deployed on all
those orgs without programmatically checking the environment.
 To reference a named credential from a callout definition, use the named credential URL. A
named credential URL contains the scheme callout:, the name of the named credential, and an
optional path. For example: callout:My_Named_Credential/some_path.
 You can append a query string to a named credential URL. Use a question mark (?) as the
separator between the named credential URL and the query string. For example:
callout:My_Named_Credential/some_path?format=json.
 In contrast, let’s see what the Apex code looks like without a named credential.
 Notice that the code becomes more complex to handle authentication, even if we stick with basic
password authentication.
 Coding OAuth is even more complex and is an ideal use case for named credentials.
Custom Headers and Bodies of Apex Callouts That Use Named Credentials:
 Salesforce generates a standard authorization header for each callout to a named-credential-
defined endpoint, but you can disable this option.
 Your Apex code can also use merge fields to construct each callout’s HTTP header and body.
 This flexibility enables you to use named credentials in special situations.
 For example, some remote endpoints require security tokens or encrypted credentials in request
headers.
 Some remote endpoints expect usernames and passwords in XML or JSON message bodies.
 Customize the callout headers and bodies as needed.
 The Salesforce admin must set up the named credential to allow Apex code to construct headers
or use merge fields in HTTP headers or bodies.
 The following table describes these callout options for the named credential.
Merge Fields for Apex Callouts That Use Named Credentials:
 To construct the HTTP headers and request bodies of callouts to endpoints that are specified as
named credentials, use these merge fields in your Apex code.
Merge Field Description
1. {!$Credential.Username}
{!$Credential.Password}
2. {!$Credential.OAuthToken}
3. {!$Credential.AuthorizationMethod
4. {!$Credential.AuthorizationHeaderValue}
5. {!$Credential.OAuthConsumerKey}
Note:

More Related Content

PPTX
REST API in Salesforce
PPT
Salesforce REST API
PDF
Api wiki · git hub
PDF
REST API and CRUD
PPTX
SFDC REST API
PDF
IRJET- Rest API for E-Commerce Site
PDF
Exchange of data over internet using web service(e.g., soap and rest) in SAS ...
PPTX
An Introduction To REST API
REST API in Salesforce
Salesforce REST API
Api wiki · git hub
REST API and CRUD
SFDC REST API
IRJET- Rest API for E-Commerce Site
Exchange of data over internet using web service(e.g., soap and rest) in SAS ...
An Introduction To REST API

What's hot (20)

PPTX
LAJUG Napster REST API
PPTX
Richarson maturity model (HATEOAS)
PPTX
Rest & RESTful WebServices
PDF
ReST (Representational State Transfer) Explained
PPTX
REST API Design & Development
KEY
A Conversation About REST - Extended Version
KEY
Rest and the hypermedia constraint
DOCX
fffSeminar
PPTX
PPSX
Rest api standards and best practices
PDF
HTTP Request and Response Structure
PPTX
PDF
Representational State Transfer (REST) and HATEOAS
PPTX
Demystify Salesforce Bulk API
PPTX
RESTful API Design Fundamentals
PPT
Webbasics
PDF
WordCamp Wilmington 2017 WP-API Why?
PPTX
Soap UI and postman
PPT
RESTful services
ODP
Creating Web Services with Zend Framework - Matthew Turland
LAJUG Napster REST API
Richarson maturity model (HATEOAS)
Rest & RESTful WebServices
ReST (Representational State Transfer) Explained
REST API Design & Development
A Conversation About REST - Extended Version
Rest and the hypermedia constraint
fffSeminar
Rest api standards and best practices
HTTP Request and Response Structure
Representational State Transfer (REST) and HATEOAS
Demystify Salesforce Bulk API
RESTful API Design Fundamentals
Webbasics
WordCamp Wilmington 2017 WP-API Why?
Soap UI and postman
RESTful services
Creating Web Services with Zend Framework - Matthew Turland
Ad

Similar to Salesforce Integration (20)

PPTX
Apitesting.pptx
PDF
Best practices and advantages of REST APIs
PDF
Rest web service
PPTX
API Testing Basics.pptx
PDF
API Basics
PDF
What are restful web services?
PDF
Rest API Interview Questions PDF By ScholarHat
PPTX
Building-Robust-APIs-ASPNET-Web-API-and-RESTful-Patterns.pptx
PPTX
Integration on Force.com Platform
PPTX
Flutter development Lecture 17 full powerpoint
PDF
Session 8 Android Web Services - Part 1.pdf
PDF
WebApp #3 : API
PDF
20 Most Asked Question on Rest APIs .pdf
PPTX
Web Programming
PDF
Rest api-interview
PPTX
Web Service
PPTX
Phalcon 2 High Performance APIs - DevWeekPOA 2015
PDF
Day1 : web service basics
PDF
Networked APIs with swift
PDF
Introduction to API
Apitesting.pptx
Best practices and advantages of REST APIs
Rest web service
API Testing Basics.pptx
API Basics
What are restful web services?
Rest API Interview Questions PDF By ScholarHat
Building-Robust-APIs-ASPNET-Web-API-and-RESTful-Patterns.pptx
Integration on Force.com Platform
Flutter development Lecture 17 full powerpoint
Session 8 Android Web Services - Part 1.pdf
WebApp #3 : API
20 Most Asked Question on Rest APIs .pdf
Web Programming
Rest api-interview
Web Service
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Day1 : web service basics
Networked APIs with swift
Introduction to API
Ad

Recently uploaded (20)

PDF
Module 1 - Introduction to Generative AI.pdf
PPTX
Foundations of Marketo Engage: Nurturing
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PDF
Top AI Tools for Project Managers: My 2025 AI Stack
PPTX
Improving Audience Engagement ROI with ERP-Powered Insights
PPTX
ESDS_SAP Application Cloud Offerings.pptx
PPTX
Comprehensive Guide to Digital Image Processing Concepts and Applications
PPTX
Greedy best-first search algorithm always selects the path which appears best...
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
PDF
Adlice Diag Crack With Serial Key Free Download 2025
PDF
Sanket Mhaiskar Resume - Senior Software Engineer (Backend, AI)
PPTX
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
PDF
Multiverse AI Review 2025_ The Ultimate All-in-One AI Platform.pdf
PPTX
FLIGHT TICKET API | API INTEGRATION PLATFORM
PPTX
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
PPTX
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PDF
Odoo Construction Management System by CandidRoot
PDF
infoteam HELLAS company profile 2025 presentation
PDF
solman-7.0-ehp1-sp21-incident-management
Module 1 - Introduction to Generative AI.pdf
Foundations of Marketo Engage: Nurturing
What Makes a Great Data Visualization Consulting Service.pdf
Top AI Tools for Project Managers: My 2025 AI Stack
Improving Audience Engagement ROI with ERP-Powered Insights
ESDS_SAP Application Cloud Offerings.pptx
Comprehensive Guide to Digital Image Processing Concepts and Applications
Greedy best-first search algorithm always selects the path which appears best...
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
Adlice Diag Crack With Serial Key Free Download 2025
Sanket Mhaiskar Resume - Senior Software Engineer (Backend, AI)
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
Multiverse AI Review 2025_ The Ultimate All-in-One AI Platform.pdf
FLIGHT TICKET API | API INTEGRATION PLATFORM
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
ROI from Efficient Content & Campaign Management in the Digital Media Industry
Odoo Construction Management System by CandidRoot
infoteam HELLAS company profile 2025 presentation
solman-7.0-ehp1-sp21-incident-management

Salesforce Integration

  • 1. Salesforce API  There are many types of APIs like REST API, SOAP API, Bulk API, and Streaming API.  Together they make up the Salesforce data APIs. REST API  REST API is a simple and powerful web service based on RESTful principles.  REST defines a set of architectural principles by which you can design Web services that focus on a system's resources, including how resource states are addressed and transferred over HTTP by a wide range of clients written in different languages.  REST API supports both XML and JSON.  Because REST API has a lightweight request and response framework and is easy to use, it’s great for writing mobile and web apps.  In layman language, Representational state transfer (REST) or RESTful web services is a way of providing interoperability between computer systems on the Internet. REST-compliant Web services allow requesting systems to access and manipulate textual representations of Web resources using a uniform and predefined set of stateless (In computing, a stateless protocol is a communications protocol in which no information is retained by either sender or receiver.” operations. When to use:  REST API provides a powerful, convenient, and simple REST-based web services interface for interacting with Salesforce.  Its advantages include ease of integration and development, and it’s an excellent choice of technology for use with mobile applications and web projects.  However, if you have many records to process, consider using Bulk API, which is based on REST principles and optimized for large sets of data.  Apex REST API when you want to expose your Apex classes and methods so that external applications can access your code through REST architecture.  Apex REST API supports both OAuth 2.0 and Session ID for authorization. Bulk API  Bulk API is a specialized RESTful API for loading and querying lots of data at once.  By lots, we mean 50,000 records or more.  Bulk API is asynchronous, meaning that you can submit a request and come back later for the results.  There are two versions of Bulk API (1.0 and 2.0). Bulk API 2.0 is easier to use.  Bulk API is great for performing tasks that involve lots of records, such as loading data into your org for the first time.
  • 2. SOAP API  It stands for Simple Object Access Protocol  It is a messaging protocol that allows programs that run on disparate operating systems (such as Windows and Linux) to communicate using Hypertext Transfer Protocol (HTTP) and its Extensible Markup Language (XML).  It is a protocol specification for exchanging structured information.  It uses a Web Services Description Language (WSDL) file to rigorously define the parameters for accessing data through the API.  SOAP API supports XML only.  Most of the SOAP API functionality is also available through REST API.  Because SOAP API uses the WSDL file as a formal contract between the API and consumer, it’s great for writing server-to-server integrations. When to use:  SOAP API provides a powerful, convenient, and simple SOAP-based web services interface for interacting with Salesforce.  You can use SOAP API to create, retrieve, update, or delete records.  You can also use SOAP API to perform searches and much more.  Use SOAP API in any language that supports web services.  Use Apex SOAP API when you want to expose Apex methods as SOAP web service APIs so that external applications can access your code through SOAP.  Apex SOAP API supports both OAuth 2.0 and Session ID for authorization. Streaming API:  Streaming API is a specialized API for setting up notifications that trigger when changes are made to your data.  It uses a publish-subscribe, or pub/sub, model in which users can subscribe to channels that broadcast certain types of data changes.  The pub/sub model reduces the number of API requests by eliminating the need for polling. Streaming API is great for writing apps that would otherwise need to frequently poll for changes.
  • 3. API Access and Authentication:  To access Salesforce APIs, you should have API enabled permission and you can integrate.  All API calls, except for the SOAP API login() call, require authentication.  You can either use one of the supported OAuth flows or authenticate with a session ID retrieved from the SOAP API login() call. API Limits  There are two types of API limits.  Concurrent limits cap the number of long-running calls (20 seconds or longer) that are running at one time.  Total limits cap the number of calls made within a rolling 24-hour period.  For a sandbox org, it’s 25 long-running calls and for a Developer Edition org, the limit is five long- running calls at once.  There are several ways to check remaining API calls: 1. API Usage box Setup--- System Overview--- API Usage Note: System Overview: give all view like API usage, custom object, Classes etc.  To setup API Usage Notifications Setup---- API Usage Notifications
  • 4. Use REST API REST Resources and Methods:  A REST resource is an abstraction of a piece of information or an action, such as a single data record, a collection of records, or a query.  Each resource in REST API is identified by a named Uniform Resource Identifier (URI) and is accessed using standard HTTP methods (HEAD, GET, POST, PATCH, DELETE).  URI is is a string of characters used to identify a resource.  REST API is based on the usage of resources, their URIs, and the links between them.  A REST request consists of four components: a resource URI, an HTTP method, request headers, and a request body.  Request headers specify metadata for the request. The request body specifies data for the request, when necessary. Note: Workbench:  Workbench is a suite of tools for interacting with your Salesforce org through the API.  URL is https://workbench.developerforce.com/login.php  Because you can make REST requests from any HTTP sender, there are plenty of other tools available for you to use (for example, check out cURL or Postman).
  • 5. Apex REST Callouts  An Apex callout enables you to tightly integrate your Apex code with an external service.  The callout makes a call to an external web service or sends an HTTP request from Apex code, and then receives the response.  Apex callouts come in two flavors. 1. Web service callouts to SOAP web services use XML, and typically require a WSDL document for code generation. 2. HTTP callouts to services typically use REST with JSON.  These two types of callouts are similar in terms of sending a request to a service and receiving a response.  But while WSDL-based callouts apply to SOAP Web services, HTTP callouts can be used with any HTTP service, either SOAP or REST. Note:  Whenever possible, use an HTTP service.  These services are typically easier to interact w ith, require much less code, and utilize easily readable JSON. Authorize Endpoint Addresses HTTP and Callout Basics:  REST callouts are based on HTTP.  Each callout request is associated with an HTTP method and an endpoint.  The HTTP method indicates what type of action is desired.
  • 6.  When the server processes the request, it sends a status code in the response.  The status code indicates whether the request was processed successfully or whether errors were encountered.  If the request is successful, the server sends a status code of 200.  You’ve probably seen some other status codes, such as 404 for file not found or 500 for an internal server error. HTTP classes: These classes expose the HTTP request and response functionality. 1. Http Class: Use this class to initiate an HTTP request and response. 2. HttpRequest Class: Use this class to programmatically create HTTP requests like GET, POST, PUT, and DELETE. 3. HttpResponse Class: Use this class to handle the HTTP response returned by HTTP.  The HttpRequest and HttpResponse classes support the following elements. a. HttpRequest  HTTP request types, such as GET, POST, PUT, DELETE, TRACE, CONNECT, HEAD, and OPTIONS  Request headers if needed  Read and connection timeouts  Redirects if needed  Content of the message body b. HttpResponse  The HTTP status code  Response headers if needed  Content of the response body  This example makes an HTTP GET request to the external server passed to the getCalloutResponseContents method in the url parameter. This example also accesses the body of the returned response.  The previous example runs synchronously, meaning no further processing happens until the external web service returns a response.  Alternatively, you can use the @future annotation to make the callout run asynchronously.
  • 7. Named Credentials as Callout Endpoints:  A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition.  Salesforce manages all authentication for Apex callouts that specify a named credential as the callout endpoint so that your code doesn’t have to.  You can also skip remote site settings, which are otherwise required for callouts to external sites, for the site defined in the named credential.  By separating the endpoint URL and authentication from the callout definition, named credentials make callouts easier to maintain.  For example, if an endpoint URL changes, you update only the named credential.  All callouts that reference the named credential simply continue to work.  If you have multiple orgs, you can create a named credential with the same name but with a different endpoint URL in each org.  You can then package and deploy—on all the orgs—one callout definition that references the shared name of those named credentials.  If you have multiple orgs, you can create a named credential with the same name but with a different endpoint URL in each org. You can then package and deploy—on all the orgs—one callout definition that references the shared name of those named credentials. For example, the named credential in each org can have a different endpoint URL to accommodate differences in development and production environments. If an Apex callout specifies the shared name of those named credentials, the Apex class that defines the callout can be packaged and deployed on all those orgs without programmatically checking the environment.  To reference a named credential from a callout definition, use the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path.  You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json.
  • 8.  In contrast, let’s see what the Apex code looks like without a named credential.  Notice that the code becomes more complex to handle authentication, even if we stick with basic password authentication.  Coding OAuth is even more complex and is an ideal use case for named credentials.
  • 9. Custom Headers and Bodies of Apex Callouts That Use Named Credentials:  Salesforce generates a standard authorization header for each callout to a named-credential- defined endpoint, but you can disable this option.  Your Apex code can also use merge fields to construct each callout’s HTTP header and body.  This flexibility enables you to use named credentials in special situations.  For example, some remote endpoints require security tokens or encrypted credentials in request headers.  Some remote endpoints expect usernames and passwords in XML or JSON message bodies.  Customize the callout headers and bodies as needed.  The Salesforce admin must set up the named credential to allow Apex code to construct headers or use merge fields in HTTP headers or bodies.  The following table describes these callout options for the named credential.
  • 10. Merge Fields for Apex Callouts That Use Named Credentials:  To construct the HTTP headers and request bodies of callouts to endpoints that are specified as named credentials, use these merge fields in your Apex code. Merge Field Description 1. {!$Credential.Username} {!$Credential.Password}
  • 11. 2. {!$Credential.OAuthToken} 3. {!$Credential.AuthorizationMethod 4. {!$Credential.AuthorizationHeaderValue} 5. {!$Credential.OAuthConsumerKey} Note: