Import an iFlow into the SAP CPI integration suite

In this blog, I am going to guide you to upload an iFlow into SAP CPI Integration suite. Once the iFlow is authorized and tested at lower environments, then those can be imported into higher environments such as Production.

In continuation to the previous blog, this blog explains the way to import the iFlow package.

Prerequisites:

  1. Authorization token. Refer to the previous blog
  2. X-CSRF-TOKEN. This token is required to import the package. To generate the X-CSRF-Token, do a GET request with the header x-csrf-token:fetch. In response headers, you get the get the value of X-CSRF-TOKEN.

The ReST APIs for the SAP is available at: https://api.sap.com/api/IntegrationContent/resource

The process to import the iFlow:

  • Prepare the headers with authorization token and x-csrf-token
headers = {
            'authorization': "Basic **************lcy5jb206U3JlZWphQDMx",
            'x-csrf-token': <x-csrf-token>,
            'content-type': "application/json"
        }
  • Convert the iFlow package to base64 as the ReST API accepts the base64 format of the package zip file.
filename = "genericreceiver.zip"
with open(filename, "rb") as f:
    bytes = f.read()
    encoded = base64.b64encode(bytes).decode('ascii')
  • Prepare the body with the base64 format of iFlow package and the target details
body = "{\r\n \"PackageId\": \"cpidemo2\",\r\n \"Name\": \"demo123456\",\r\n \"ArtifactContent\": \""+ str(encoded) +"\"\r\n}"
  • PackageId is the name of the package in which we want to upload the artifact.
  • Name represents with which name we want to upload the iFlow
  • ArtifactContent is the converted base64 content of the iFlow zip package
  • Now, make a POST request to import the iFlow

URI: https://<your SAP instance ID>.cfapps.us10-001.hana.ondemand.com/api/v1/DeployIntegrationDesigntimeArtifact

respon = client.request("POST", url, headers=headers, data=body)
if respon.status_code != "201":
    print("iFlow upload failed")
    print(respon.text)
    sys.exit(1)
  • By default, the imported iFlow package is versioned as 1.0.0. You can add the version information in the request body.

Make a post request and if you get 201 as the response code, then the package is accepted and will be uploaded. The upload process may take a few seconds. After a few seconds, you can verify the artifact on the SAP CPI console.

Hope the blog helps you.

Bhaskar Desharaju
Bhaskar Desharaju

He is an IT enthusiast, a blogger, and a DevOps practitioner. He works as Associate Architect in the DevOps/SRE space. He loves exploring new technologies, reading books and articles. In his leisure time, he spends time with family and friends.

Leave a comment

0 Shares
Share via
Copy link
Powered by Social Snap