MuleSoft SharePoint API Integration

Author: Shekh Muenuddeen

SharePoint helps organizations to share and manage content, knowledge, and applications to empower teamwork, quickly find information, and seamlessly collaborate across the organization.

MuleSoft SharePoint API allows developers to access, add, modify from anywhere at any time.

In this blog, I am going to explain exactly how we are getting started with SharePoint API to upload files, update metadata, and download files.

We know that when accessing SharePoint content we need the appropriate credentials. Below are the ways we can obtain them:

  1. Basic Username and Password
  2. Oauth JWT
  3. Oauth SAML
  4. Oauth Username and Password
  5. Oauth 2.0 

I am going to connect to Sharepoint through Oauth 2.0.

In order to get a token from Sharepoint Oauth server we need to do App registration in Microsoft Azure Oauth Provider.

SharePoint App Registration

To register an app in SharePoint navigate to the “New App Registration” page. The URL of that page will be similar to

  1. Fill the details based on the screenshot below Screenshot  – 1.
  2. Copy the generated client id and client secret.
  3. App successfully registered we need to provide the permission so that it can access the data.
  4. In order to do that, Please go to the App Id and click on lookup Screenshot  – 2.
  5. In “Permission Request XML” paste the following contant it has FULL control access Screenshot  – 2, create and trust it.

Permission Request XML

<AppPermissionRequests AllowAppOnlyPolicy="true">
  <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl"/>

Screenshot  – 1

Screenshot  –  2

Retrieve Token

Now it’s time to generate a token using MuleSoft HTTP Requester from MS Azure Oauth Provider.

Please refer the below configuration as I have provide the information which will required to generate token

Content Typeapplication/x-www-form-urlencoded

HTTP Request Configuration

HTTP Request Body

HTTP Requester Output

    "token_type": "Bearer",
    "expires_in": "86399",
    "not_before": "1587197160",
    "expires_on": "1587283860",
    "resource": "00000003-0000-0ff1-ce00-000000000000/******<TenantID>",
    "access_token": "Token"

This Token we will use for a SharePoint API which will help us to integrate with SharePoint Data.

File Upload Operation


  1. payload.Name – File name which will be uploading
  2. Use ListItemAllFields as expand because it will gives us the file uploaded id which unique identifier to refer file for subsequent operation
Base Path******
Path#[“/_api/Web/GetFolderByServerRelativeUrl(‘/sites/Docs/Contracts’)/Files/add(url='”++ payload.Name ++”‘,overwrite=true)?\$expand=ListItemAllFields”]
HeadersAuthorization: Bearer Token, Accept: “application/json”
BodyMethodFile Content as BinaryPUT

HTTP Requester configuration to upload file

Id is retrieved from Response payload which will be use for update metadata

File Update MetaData 

I am going to update file metadata as “SF Reference number” using sharepoint api

Refer screenshot SF Reference number

Notes – vars.vId we got from file upload api using expand = ListItemAllFields

Base Path******
Path#[“/_api/lists/getbytitle(‘Contracts’)/items(” ++ vars.vId ++ “)”]
BodyPlease see below as I have write DataWeave code
“Authorization” : Bearer Token
“Accept” : “application/json;odata=verbose”
“Content-Type” : “application/json;odata=verbose”
“X-HTTP-Method” : “MERGE”
“If-Match” : “*”

HTTP Request Body

%dw 2.0
output application/json encoding = "iso-8859-1"
  "__metadata": {
    "type": "SP.Data.ContractsItem"
  "SF_x0020_Reference_x0020_Number": vars.accountId

HTTP Requester configuration Update Meta Data

That’s exactly how we update the file metadata.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.