Power Automate – Send Data to SAP Hana S4

This blog will discuss how to send data to SAP Hana from Power Automate.


I recently had an opportunity to work on a project involving SAP integration. Power Apps (model-driven App) is the front end where users enter the customer’s information, calling it “Business Partner.” Information is gathered from multiple teams or departments, gets approvals, and is finally reviewed by the Data governance team. 

We used a few Power Automates for notifications and approvals. Finally, we used another Power Automate to send or post data to SAP Hana S4 through API.

Final/Complete Flow

  1. Trigger when Data Governance Approved
  2. Send Get Request to SAP to fetch/get token
  3. Parse the response to get Cookie and token
  4. Extract Cookie
  5. Send to SAP
  6. Parse the response to get SAP ID
  7. Update Dataverse/Power Apps with the newly created SAP ID


Explanation (Step by Step)

  1. Power Automate flow is triggered when the Data governance team approves it.

Trigger conditions



2. Send the GET request to SAP by passing basic authentication (Username and Password)

Add an action called “HTTP” and set the inputs/parameters

There are multiple ways to store the username and password like

  • Environment Variables
  • Having Dataverse table as Persona or Configuration
  • Azure Key Vault

I just used environment variables for the demo, but for the client project, we implemented Azure key vault.

URI: https://DEVS4.PROTIVITI.COM:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$format=json&$top=1

Method: GET

Authentication : Basic (Add Username and Password)

  • Make sure to set the headers so that we will get the token in the response.
  • Key : x-csrf-token, Value: fetch

3. Parse the Headers so that we can get the token

    • Insert a compose action and name it “GET Request—Headers Output—Compose” to display/debug the headers. This is only for testing purposes, and you can remove it once development is completed.
    • Insert action “Parse JSON”
      1. Set content as Headers from the previous Get Request
      2. Add schema by using “Use Sample payload to generate schema”
        1. Click the link “Use Sample payload to generate schema”
        2. A new Popup window will open and enter the JSON Headers from the previous Get Request
        3. Click “Done”
        4. Schema should be filled automatically

    • Insert compose action and set properties from parse action. 
      • body(‘Parse_GET_Request’)?[‘Set-Cookie’]

4. Add another compose action call it “Get Cookie”. Removing a few chars which don’t need when we sent to SAP on POST action

replace(replace(body(‘Parse_GET_Request’)?[‘Set-Cookie’],’path=/,’,”),’secure; HttpOnly’,”)

5. Insert another “HTTP” action to send /post data to SAP

    • Method: Post
    • URI: https://DEVS4.PROTIVITI.COM:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner
    • Headers (Make sure to set the below headers)
      • x-csrf-token: body(‘Parse_GET_Request’)?[‘x-csrf-token’] 
      • cookie: body(‘Parse_GET_Request’)?[‘Set-Cookie’]
      • Content-Type: application/json
      • Accept: application/json
    • Cookie
    • Body

“OrganizationBPName1”: “Learn to Illuminate”,
“OrganizationBPName2”: “LLC”,
“BusinessPartnerCategory”: “2”

  • Content-Type: application/json (Means what format we are sending data to SAP)
  • Accept: application/json (What format like to recieve from SAP)

6. Parse JSON

  • Need to parse the JSON response to get SAP ID
  • Set the content as the Body of the previous Send to SAP action
  • Generate the Schema from the Sample

7. Set the SAP ID in Dataverse

    • Add an action “Dataverse”
    • Add “Update a Row”


We can send or post data from Power Apps to SAP Hana S4 using the Power Automate HTTP action.

Leave a Reply

Your email address will not be published. Required fields are marked *