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:
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