Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Sriprasadsbhat
Active Contributor
In below blog would like to share how we can integrate Google Drive with SAP CPI using SAP Cloud Platform Open Connectors service.

Scenarios:

Will explain end to end scenarios of get and post file using POSTMAN http client.



Google Application Creation:

In order to consume Rest APIs of Google Apps we need to create application that communicates securely with SAP CP Open Connectors.

Step 1:

Login to https://console.developers.google.com and follow below steps



Step 2:

Create new project with valid logical name.





Step 3:

Click on the created project and navigate to APIs & Services dashboard.





Step 4:

Enable to Google Drive API to consume it in the application.



 



Step 5:

Once you enable the required API navigate back to Credentials tab of APIs & services to create credentials that can be used in OpenConnectors.







Once done save it.

Step 6:







Open Connectors Configuration:

Step 1:

Login to your Open Connectors account and search for Google Drive connector.Click on Authenticate



Step 2:

Click on view Optional Fields and enter  API key and Secret copied from Google Application.



Step 3:

Once you click on Create Instance button in previous step it will open new window to authenticate with your Google Credentials.Proceed with the same and click on allow application to access your google drive data.





Step 4:

Now you have successfully established the connectivity.Now click on Test in the API docs to make sure you are able to perform smoke test and able to copy the Authorization header & end point url which can be used in your SAP CPI iflow.





now fill the required details and click on execute button.



its time to see the result and copy the credentials.



Creation of IFlow [ get call from SAP CPI ]:

Create an IFlow like below to query the file from POSTMAN and get the file content back.



Step 1: 

Add communication channel of type HTTPS and give address like below.



Step 2: 

Add content modifier to delete all unwanted headers and set property containing file name with path which can be used in your receiver communication channel.





Step 3:

Add content modifier to set authorization header ( value copied from Open Connectors Step # 4 last screen ).



Step 4:

Add HTTP communication channel with below configuration ( url copied from your Open Connectors Step# 4 config ).



Time to Test your scenario:

Open POSTMAN and copy of the endpoint url of your IFlow ending with /getFile and copy paste the below XML in body.
<Root>
<FilePath>/OpenConnectors/EDI_SAMPLE.txt</FilePath>
</Root>



Creation of IFlow [ Post call from SAP CPI ]:

Create an IFlow like below to post file from Postman and store it in Google Drive.

Note: As highlighted below Allowed Headers needs to updated with value content-type|fileName



Step 1: 

Add communication channel of type HTTPS and give address like below.



Step 2: 

Add content modifier to set property containing file name with path which can be used in your receiver communication channel.



 

Step 3:

Add content modifier to set authorization header ( value copied from Open Connectors Step # 4 last screen ).



Step 4:

Add HTTP communication channel with below configuration ( url copied from your Open Connectors Step# 4 config ).



Time to Test your scenario:

Open POSTMAN and copy of the endpoint url of your IFlow ending with /posttFile and follow below screen in order to set header containing file name with path & upload the file in form-data format with key "File".



 

And when you click on send ,you are done with posting file to Google Drive with below response with a file in Google Drive folder.





Reference:

[ 1 ] - Open Connector Blog series

Hope this helps!

Regards,

Sriprasad Shivaram Bhat

 

 

 

 
17 Comments