Technical Articles
Placing Files in SharePoint using APIs in SAP PI/PO
Hello All,
Recently, I’ve got a requirement to integrate SAP PI with Microsoft SharePoint. Pick the files from SAP AL11 directory and upload the files in SharePoint Folder.
How to integrate SharePoint with SAP PO?
SharePoint adds the ability for you to remotely interact with SharePoint sites by using REST APIs. Now, developers can interact remotely with SharePoint data by using any technology that supports REST web requests. This means that developers can perform Create, Read, Update, and Delete (CRUD) operations.
Prerequisites:
1.) SharePoint Access Token Url (OAuth)
2.) File Placing/Uploading Url
Steps to generate OAuth Token :
Token Url : https://login.microsoftonline.com/{tenant_id}/tokens/OAuth/2
Method : POST
Headers : Content-Type: application/x-www-form-urlencoded
Body :
- grant_type = client_credentials
- client_id = {client_id}@{tenant_id}
- client_secret = {client_secret}
- resource = 00000003-0000-0ff1-ce00-000000000000/hostname@{tenant_id}
- scope = http://sharepoint/content/sitecollection/web
File Place/Upload Url :
https://{siteUrl}/_api/web/GetFolderByServerRelativeUrl(‘{FolderName}’)/Files/add(url='{fileName}’,overwrite=true)
Pass Access Token as a Header:
Authorization : Bearer {access_token}
Upload the file as binary as shown below
Configuration in SAP PO :
SFTP Sender Channel :
Enable ASMA for dynamic FileName to be used while placing the files in SharePoint Folder
Dynamic Configuration Bean configured in sender channel to store the FileName property
REST Receiver Channel :
Use standard OAuth functionality available in the REST communication channel.
URL Pattern: https://{siteUrl}/_api/web/GetFolderByServerRelativeUrl(‘{FolderName}’)/Files/add(url='{FileName}’,overwrite=true)
HTTP Headers: Pass OAuth Token as a Header Parameter.
Testing :
The Files are placed in SharePoint folder Successfully….!!!!
SharePoint Folder :
Note : Import SharePoint SSL Certificates in NWA –> Configuration –> Certificates and Keys –> Trusted CAs
I hope this will helpful and please let me know the feedback.
Is there any size limitation to upload and download files ?
Hi Subramanyam Naragani,
The maximum size of a binary file that you can create with REST supports up to 2 gigabytes (GB).
Thanks,
Anil Wesley
Hi Anil,
I have tried same steps which you given, but still i am getting HTTP Communication Error. Could not retrieve oAuth Token.
Please let me know if you faced similar issue ?
Thank you..
Rakesh
Hi Anil,
Its working now , after fixing a few errors in the url pattern .
Thanks for creating such relevant blog.
Much Appreciated.
Br,
Rakesh N
Thanks Rakesh