Integrate SharePoint with Salesforce using Microsoft Graph API

Integrate SharePoint with Salesforce using Microsoft Graph API

Why Integrate with SharePoint?

One of the main reasons is the revenue cost. With SharePoint integration, an organization can save a lot in Salesforce’s storage costs. A standard SharePoint storage is 1 TB. If that is not enough, extra storage is available at a very reasonable price of $0.20/month per GB (exact plans are available online).

Getting Familiar With SharePoint Terms

  1. Tenant: A tenant represents an organization. It’s a dedicated instance of Azure Active Directory received after signing up for a Microsoft Azure account.
  2. Site: It is a website that contains different SharePoint Web components like Document Library, Calendar, Task List, etc. There can be multiple Sites under a single Tenant.
  3. Document Library: A secure place to store files related to a specific project or a client so as to collaborate among co-workers.
  4. Drive: The drive resource is the top-level object representing a user’s OneDrive or a document library in SharePoint.
  5. Drive Item: The driveItem resource represents a file, folder, or other item stored in a drive.


Before we start writing Apex classes to make callouts, we need few basic information to communicate with SharePoint. It is advisable to seek help from the SharePoint admin team for carrying out the steps mentioned below.

  1. Login to Microsoft Azure account.

    Click on Azure Active Directory.

  2. Create an app in the Azure Portal for the Tenant.

    Click on App registrations on the left panel.

    Click on New registration.

    Enter the App name and select the options as shown in the image.

    Click on Register.

    Note down the Client Id and Tenant Id.

    Click on Authentication from the left panel.

    Click on Add a platform. Select Web.

    Enter the Redirect URI as your Salesforce org domain.

    Ex: https://<domain-name>

    Ensure the checkboxes shown in the image are checked.

    Click on Certificates & secrets.

    Click New client secret. Once generated, note down the Client Secret value.

  3. Request for API permissions (usually granted by SharePoint admin)

    Click Add a permission. Select Microsoft graph. Select the permissions as shown above for Delegated and Application permissions.

    Note: Delegated permissions are for user based API requests and Application permissions are temporary access token based API requests. For Application permissions, SharePoint Admin should grant explicit access.

  4. Create a SharePoint Site where the documents need to be stored and note down the SharePoint Site Id by hitting this URL in the browser: https://<tenant><site-url>/_api/site/id

Integration using Microsoft Graph API

Microsoft Graph API exposes various endpoints where requests can be sent over HTTP protocol. It uses the REST API standards and its online documentation is readily available for development, as a result of which we have more control on the SharePoint side.

Once all the prerequisites have been met, we need to prepare our Salesforce Org to integrate with the SharePoint App that we created.

    1. As a best practice, store Tenant Id, Client Id, Client Secret in a Custom Metadata record in Salesforce for making callouts. Specify the name of the record as Azure_App for ease of identification. Store Azure Grant Type=client_credentials, Azure Scope= as static values in the same record as they will be the same for all callouts.
    2. Create two Remote Site Settings:
      1) Name=Microsoft_Graph, URL=
      2) Name=Microsoft_Login, URL=
  1. Create an Apex class to make callouts.

    Firstly, we need a temporary access token to be specified in the HTTP request header to make any callouts.

    All the necessary details are fetched from the Custom Metadata record and a POST request is made with required URL parameters to fetch the access token.

    Every subsequent callout should hold these request headers. Note that the Authorization header has the value Bearer <space><access_token>.

    Assuming you have a custom component to upload file and convert the file data to bae64 string, the next step is to form the parameters as shown above and call the method in order to make a callout to SharePoint endpoint.

    To create a folder as shown above, pass the required parameters and make a callout.

Key Takeaway

Using the Microsoft Graph API we can create Salesforce components to Read the entire document library, Create folders, Upload files, Download files from SharePoint.

Leave a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

DocuSign CLM the ultimate tool for managing contracts
DocuSign CLM: The Ultimate Tool for Managing Contracts
salesforce ui design update a detailed overview
Salesforce UI Design Update: A Detailed Overview
dreamforce 2024
Dreamforce 2024: A 3-Day Event of Learning, Connection, and Inspiration
how-can-slaesforce b2b commerce cloud increase customer engagement
How Can Salesforce B2B Commerce Cloud Increase Customer Engagement
salesforce for financial services transforming customer engagement operational effectiveness
Salesforce for Financial Services: Transforming Customer Engagement & Operational Effectiveness

How can i help you? close button

powered     by   ABSYZ
Scroll to Top