Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 

Integrating our systems with third-party platforms like GitHub has become a common requirement in today’s business landscape, especially when working with public repositories that store documentation and configuration files.

In this blog post, I’ll walk you through how to connect SAP Open Connectors for GitHub with SAP Cloud Integration (CPI) to fetch a file from a GitHub repository and decode its contents. We’ll use SAP Open Connectors to securely access GitHub resources and apply a Groovy script in CPI to decode the Base64-encoded file content, helping you build a simple and reliable end-to-end integration.

By the end of this blog, you’ll have a clear understanding of how to:

1. Set up a GitHub instance in SAP Open Connectors

2.Connect SAP Open Connectors with SAP Cloud Integration (CPI)

Step 1: Fetching and decoding file content using Groovy scripting

To begin, you first need to create a GitHub instance in SAP Open Connectors. Start by logging in to the SAP BTP Cockpit and navigating to the SAP Open Connectors dashboard. This is where you’ll configure and manage your GitHub connection before using it in SAP Cloud Integration.

SanalaTejaswini_10-1752737524746.png

 

To get started, select the GitHub connector from the list of available connectors in SAP Open Connectors.

SanalaTejaswini_11-1752737881367.png

 

Next, enter your GitHub details. Provide your GitHub account name and the repository name. Make sure the repository you choose is public, as this is required for access without additional authentication

SanalaTejaswini_2-1752730926361.png

Once the details are filled in, click Create Instance. This will open the configuration screen where you can complete the setup for your GitHub instance.

 

Step 2: Testing GitHub APIs using Interactive API Docs

Before connecting everything to SAP Cloud Integration, it’s a good practice to test the GitHub connector using the Interactive API Docs provided by SAP Open Connectors. This helps confirm that your GitHub instance is correctly configured and able to retrieve data from your repository.

To do this, open the GitHub instance you just created from the SAP Open Connectors dashboard and navigate to the Interactive API Docs section.

Here, you’ll need to provide the required parameter, such as the file path within the repository (for example, /notes.md). After submitting the request, you’ll receive a JSON response.

SanalaTejaswini_12-1752738502005.png

After submitting the request, you’ll receive a JSON response. One of the key fields in this response is the content field, which contains the file data encoded in Base64 format.

This confirms that your GitHub instance is set up correctly and is able to access files from the specified public repository. In the next steps, this Base64-encoded content will be decoded in SAP Cloud Integration (CPI) using a Groovy script.

SanalaTejaswini_13-1752738869810.png

 

Step 3: Storing Open Connectors Credentials in Security Material

Before using SAP Open Connectors in your iFlow, you need to store the required credentials in SAP Integration Suite.

SanalaTejaswini_5-1752731226288.png

 

Step 4: Connecting SAP Cloud Integration (CPI) to GitHub using Open Connectors

Once your GitHub instance is set up and running, the next step is to connect it with SAP Cloud Integration so you can retrieve file content from the repository.

To do this, start by creating a new iFlow in your CPI workspace. Add a Sender step, such as a Timer or HTTPS adapter, based on how you want to trigger the flow. Then, add a Receiver step.

For the Receiver, choose the Open Connectors adapter from the list of available adapters. This adapter will be used to connect CPI with GitHub through SAP Open Connectors.

SanalaTejaswini_6-1752731292140.png

 

SanalaTejaswini_7-1752731311253.png

Deploy the iFlow and trigger it to run. This will call the GitHub API and fetch the file content, which is returned in a Base64-encoded format.

Once the file content is successfully retrieved from GitHub, you’ll see a response similar to the one shown below.

SanalaTejaswini_8-1752733083529.png

 

Step 5: Fetching and decoding the file content

At this stage, the file content fetched from GitHub is still in Base64 format, which isn’t readable. To convert it into plain text, you can use a Groovy Script step in your iFlow.

Add a Script step and use the following Groovy code to decode the content:

import com.sap.gateway.ip.core.customdev.util.Message
import java.util.Base64

def Message processData(Message message) {
    def body = message.getBody(String)
    def json = new groovy.json.JsonSlurper().parseText(body)
    def encodedContent = json.content
    def decodedBytes = Base64.decoder.decode(encodedContent)
    def plainText = new String(decodedBytes, "UTF-8")
    message.setBody(plainText)
    return message
}

 

This script reads the Base64-encoded content from the API response, decodes it, and replaces the message body with the decoded, human-readable text.

After the Groovy script runs successfully, the file content appears as plain text, making it easy to read and use in further processing steps.

SanalaTejaswini_9-1752733713227.png

Conclusion :

In this blog, we explored how to connect to a public GitHub repository, retrieve file content, and decode it using Groovy scripting in CPI. In the next blog, we’ll take this a step further and look at how to work with private repositories using authentication tokens.

If you have any questions or would like a downloadable iFlow sample, feel free to drop a comment.

1 Comment
Labels in this area