Integrate SharePoint using SAP PI
Here, we will see how we can integrate with SharePoint to Read/Write data using SAP-PI techniques without REST-Adapter.
We can interact remotely with SharePoint data using any technology/platform which supports REST (Representational State Transfer service) web requests.
SharePoint provides specific REST-API-protocols which can be used for data exchange with SharePoint. We can perform CRUD operations (Create, Read, Update, and Delete)
A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data (real time data exchange over internet).
For any data exchange with SharePoint via respective REST-API, we need to follow following steps:
- Get “SharePoint access token” for authroization
- then perform CRUD (create/Read/Update/Delete) operations using POST/GET/PUT/DELETe methods.
For authorization, to fetch “SharePoint access token”, we need following SharePoint details:
- Client-Id or App-Id: Client ID is a GUID for the SharePoint Add in
- Tenant-Id: Tenant ID is SharePoint Online Site Realm
- Client-Secret: Client Secret is the password for the add-ins.
And while fetching “SharePoint Access Token”, we may get following permission issue:
- “Access denied. You do not have permission to perform this action or access this resource”
To resolve above issue/error, we need to provide “Write” permission to our SharePoint client-id/app-id with below xml input in SharePoint:
<AppPermissionRequests AllowAppOnlyPolicy="true"> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Write" /> </AppPermissionRequests>
and to do this (granting write-permission) in SharePoint site for our client-id/app-id, we can follow following Microsoft-help-link and screen:
- Granting access using SharePoint App-Only
- page section, where “FullControl” is been given, here only “Write” permission is required
In SAP-PI where REST Adapter is not available (say till version SAP-PI 7.1), then without REST-Adapter, following techniques can be used in SAP-PI to consume SharePoint-REST APIs for data Exchange:
Using SAP-PI Java UDFs (User defined functions)
- Inside Graphical Mappings, we can write UDFs to Read/Write data in SharePoint with respective SharePoint-REST API’s consumption.
- For any Read/Write event, first we need to fetch SharePoint-Access token for Authentication to SharePoint and next, we can use Respective SharePoint-REST for Read/Write events.
- To fetch “SharePoint Access Token”, which is required for authentication of SharePoint’s CRUD REST-APIs, following blog’s UDF example can be used:
- To write any data inside SharePoint, following blog’s UDF example can be used:
- To read SharePoint data, following blogs’ UDF example can be used:
- To create/Read files into/from SharePoint, following blog’s UDF examples can be used:
Using SAP-PI Java Maps
- We can write custom Java Programs to consume SharePoint REST-APIs for Read/Write operations, these program can be used in SAP-PI interfaces.
- Following are the few SAP-PI JavaMap examples where different operations are been performed as per different business requirements via consuming respective SharePoint REST-API’s
- To send PDF files from SAP-ECC’s app directory to SharePoint’s specific folder location:
- To write data into Sharepoint in batch/bulk via single call
- To update data into Sharepoint in batch/bulk via single call
- The purpose of this blog is to club all my blog’s info written for SharePoint integration.
- This blog will be kept on updating with new SharePoint techniques using SAP-PI as soon as it comes in my integration journey path
- Next plan is try “OAuth 2.0 authentication” using std. REST Adapter
….to be continued
Dilip Kumar KrishnaDeo Pandey
Nice blog keep On 🙂
I was trying to Get a PDF file from sharepoint using swift webview and jamfkeychain , problem I am facing is that the SAP Sharepoint login screen is rendered rather the PDF. What pass through to use, can you help.
To read SharePoint files, I hope you must be using correct respective REST API.
I have one example where .txt file was read as can be referred in below blog link, please check:
refer section " JavaCode to retrieve all files of a folder from SharePoint:"
Thanks & Regards,
Dilip K K P
Thanks Dilip. I acknowledge your help and an article on global-sharepoint.com where the fields to be used are explained in detail. In 4 steps access SharePoint online data using postman tool | Global SharePoint Diary (global-sharepoint.com)
I have been successful in connecting to SharePoint from PO 7.5 using the REST OAuth 2.0 adapter with zero coding and to create a folder in SharePoint.
It looks like SharePoint ignores the fields "Client ID:" and "Client Secret:" as these have to be supplied as Additional Parameters. Please take not of the Parameter Types. These dictate whether they are send in the http header or in the URL. The example below works.
Screen shot of OAuth settings
Since I want the response in xml, I set Accept xml, but you can use json.
Screenshot of HTTP Headers
Thanks for sharing the information, I will surly try from my side using REST-Adapter.
I had explored the Java-Program techniques because, from one end, I had to invoke a API to get the pendingCounts of employees and on other end, sending the count to Sharepoint via PI7.1 where REST adapter was not present. Now, we have PO7.5, so it's good to explore REST adapter with Sharepoint-APIs
Thanks & Regards,