One of the greatest strengths of Salesforce is its ability to integrate with third-party applications through REST API. Whether you’re connecting with a custom web app, an ERP, a payment gateway, or a marketing platform REST API enables smooth two-way communication.
In this article, you’ll learn how to:
- Authenticate into Salesforce from a third-party app.
- Send a REST API request from the external app to Salesforce
- Display Salesforce data on your own UI using HTML + JavaScript
🔁 Integration Workflow
- Authenticate using OAuth 2.0 and get an access token.
- Use the token to call Salesforce REST API endpoints.
- Fetch or push data to/from the external application.
💻 HTML + JavaScript Code Example (Read from Salesforce)
⚠️ Ensure you have a valid accessToken and instanceUrl.
<!DOCTYPE html>
<html>
<head>
<title>Salesforce Third-Party Integration</title>
</head>
<body>
<h2>GET Contacts FROM Salesforce</h2>
<button onclick="fetchContacts()">Fetch Contacts</button>
<div id="response"></div>
<script>
async FUNCTION fetchContacts() {
const accessToken = "YOUR_ACCESS_TOKEN";
const instanceUrl = "https://yourInstance.salesforce.com";
const response = await fetch(`${instanceUrl}/services/data/v59.0/query?q=SELECT+Id,FirstName,LastName+FROM+Contact+LIMIT+5`, {
method: "GET",
headers: {"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json"
}});
const RESULT = await response.json();
document.getElementById("response").textContent = JSON.stringify(RESULT, NULL, 2);
}</script>
</body>
</html>
✅ Conclusion
REST API allows third-party applications to communicate with Salesforce in real-time, making it ideal for automation, real-time dashboards, or CRM synchronization. With proper authentication and API calls, you can fetch or manipulate any Salesforce object easily.
In the next tutorial, we’ll show how to push data from a third-party app to Salesforce using POST method.
How does the REST API work in Salesforce?
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). REST API is based on the usage of resources, their URIs, and the links between them. You use a resource to interact with your Salesforce org.
How does Salesforce integrate with other applications?
The integration tool will connect to Salesforce using APIs and authentication. Connections to target apps must also be configured. With connections in place, data fields must be mapped between Salesforce and external objects. This mapping ensures data aligns correctly on syncing.
What is the difference between connect REST API and REST API in Salesforce?
Connect REST API differs from REST API in multiple ways, including: Data is structured for rendering on websites and mobile devices. Returned information is localized to the user's time zone and language. Changed values that are tracked in a feed are returned as value-pair representations.
Related Topics | You May Also Like
|
👉 Get Free Course →
📌 Salesforce Administrators 📌 Salesforce Lightning Flow Builder 📌 Salesforce Record Trigger Flow Builder |
👉 Get Free Course → |