Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
siddhartha_routh
Explorer
1,704

In Part 1 of this series, we established secure connectivity between SAP CPI and SharePoint using Azure AD and OAuth 2.0 authorization code. With this foundation in place, we’re now ready to create an API that allows external applications to upload files directly to SharePoint through SAP CPI. This API, when exposed via API Management (APIM), can serve as a bridge for boundary applications to seamlessly push files to SharePoint.

This is part two of the three-part blog series which will guide us through the essential steps for SAP CPI and SharePoint integration:

  • Part 1 - Establishing Connectivity - We covered the foundational setup for secure connectivity between SAP CPI and SharePoint, including permissions in Azure AD and OAuth 2.0 configuration in CPI
  • Part 2: Creating an API to Upload Files — We’ll walk through creating a custom HTTP API and exposing it via APIM to enable file uploads to SharePoint.
  • Part 3: Reading Files from SharePoint — In the final part, we’ll explore how to use the Microsoft SharePoint sender adapter to read files and perform post-processing actions.

This post will walk you through setting up a custom HTTP endpoint in CPI, configuring it to handle file uploads, and exposing it through APIM for external access.


Step 1: Design the Integration Flow in CPI

First, we’ll create an integration flow in CPI to handle file uploads. This flow will serve as the core of our API, receiving files from external systems and forwarding them to SharePoint.

We are not gonna go through the nitty gritty on how to create an Integration Flow but in the below section focus on the configurations more specific to SharePoint. 

  • Create a New Integration Flow

    • In CPI, go to the Design workspace and create a new integration flow.
    • Name it something descriptive, like "SharePoint_FileUpload."siddhartha_routh_0-1730446946355.png

 

  • Configure the HTTP Adapter

    Update the Maximum File Size from default of 40 MB to the maximum file size expected in the conditions tab of the HTTP adapter.  

     
     
    siddhartha_routh_4-1730447175343.png

 

  •  Optional Step : Map the Incoming File Data

    Our use case had specific requirements to create a folder hierarchy dynamically based on the Customer Number and Order Number passed as a custom header in the HTTP request , along with the File Name.  
    To achieve that we are creating an exchange property "FilePath" which has an expression of "/CUST-${header.CustNo}/ORD-${header.OrderNo}" 
    siddhartha_routh_5-1730448982109.png
  • Use SharePoint adapter to upload the file
    Local Integration Process to upload the file. 

siddhartha_routh_6-1730449440572.png

Set Content-Type as "application/octet-stream" using a Content Modifier. 

siddhartha_routh_7-1730449586316.png

Set the Message Body as the Body of the original HTTP request created as an exchange property which will be a binary stream data of the file uploaded. 

siddhartha_routh_8-1730449704110.png

Add the below details in the SharePoint Adapter to upload the files. 
Please make sure to select Authentication Type as OAuth2 Authorization Code.  

siddhartha_routh_0-1730450374321.png

siddhartha_routh_1-1730450568802.png

Step 2: Testing the Integration Flow

We can test the above integration flow from postman . 
As shown in the below screenshot we are sending the Customer Number , Order Number and File Name as part of the HTTP header. 

Request

siddhartha_routh_4-1730451700782.png

siddhartha_routh_5-1730452101899.png

Response

siddhartha_routh_6-1730452326796.png

As you can observe below based on the File Path i.e. "/CUST-${header.CustNo}/ORD-${header.OrderNo}" mentioned in the adapter the SharePoint adapter automatically created the folder structure and placed the file in the last folder. 
If the folder structure already exists it uploads the file to the target folder without creating duplicate folders.  

siddhartha_routh_9-1730454204301.png

siddhartha_routh_10-1730454651113.png

siddhartha_routh_11-1730454724264.png

 

Set Up the API Endpoint in API Management (APIM) - SharePoint Specific Changes

While the general process of creating APIs in APIM has been covered extensively in other blogs, here we’ll focus specifically on configurations tailored for SharePoint integration. 
You can refer to the below blogs if you need more info on the same.

We’ll also address how to handle large data uploads by enabling streaming, which not only enhances performance but also bypasses APIM's default 10 MB size limit. These adjustments are crucial when working with file uploads to SharePoint, where larger files are often encountered.

Add the below property to both Proxy End Point and Target End Point to enable the APIM to handle streaming of large amount of data. 
siddhartha_routh_7-1730453499429.png

siddhartha_routh_8-1730453959272.png

Conclusion

In this second part of our series, we’ve set up a custom API in SAP CPI to upload files to SharePoint and exposed it securely through API Management. This API enables boundary applications to send files directly to SharePoint, expanding the integration’s reach. In the final post, we’ll dive into how to retrieve and manage files from SharePoint using the Microsoft SharePoint sender adapter in CPI, along with post-processing actions. Stay tuned for Part 3, where we bring the integration full circle!

Resources
 Enable Streaming of Requests and Responses in an API Proxy 

2 Comments
KaushikCPI
Discoverer
0 Kudos

Thanks for this blog. This was very helpful.

Duangporn
Discoverer

Thank you very much for these series!! 🙏 @siddhartha_routh 
I'm encountering the issue to integrate with SharePoint for now.
So it's really helpful for me.
And looking forward for the part 3 also.

Labels in this area