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: 
Hello Everyone,

I wanted to user RAP based API in sap cloud in my workflow service task to get/update the data from BTP Workflow to S4 public cloud. When I was trying with service URL with direct basic authentication as destination in BTP, it wasn’t giving me the result as authentication which comes when we try from eclipse will not allow us to get the data. Instead, I was getting response as HTML data.

I have explored few of the blog to connect service from RAP, but none of them was giving solution to connection RAP API directly from Workflow. After several reads, some YouTube videos, hit and trial I was able to trigger service from workflow.

Here I am illustrating how we can use RAP rest API in workflow service task. Following are the steps covered.

  1. Create XSUAA service instance and service key to enable trust from workflow user to RAP based web API in cloud.

  2. Create destination to consume REST API in workflow service task with XSUAA trust service token and default identity provider credentials.

  3. Using Workflow service task to call API


When we want to do GET or POST request through BTP workflow management, we need to create destination in our BTP subaccount. When we try to connect BTP workflow service to our SAP S4 Public cloud API it needs to be authenticated using default identity provider. We need to authenticate this workflow service user XSUAA to get initial token

Go to BTP subaccount's and create instance for Authorization and Trust Management Service and this will create XSUAA service instance.


Provide the details for Plan as apiaccess and name for instance and click on create.


It will take few seconds and now you can go to instance with name you created and create a service key. Below is the service key which I already created.


Open the service key data and copy URL, Client Id, Client Secret. These will be used in to create new destination.


Go to destination tab and create new destination. Before that just get the URL of your RAP based web API created in eclipse. Go to service binding and select your web API and click on service URL.


Copy the URL and replace and remove '-web' from URL

https://1e40e2cb-b1df-4e5e.abap-web.eu10.hana.ondemand.com/sap/opu/odata/sap/ZRET_C_COMPWFSTATUS_API...

Target URL will look like this.

https://1e40e2cb-b1df-4e5e.abap.eu10.hana.ondemand.com/sap/opu/odata/sap/ZRET_C_COMPWFSTATUS_API/?sa...


Now go to destination and click on create destination with below parameters


 

Take URL from service URL

User and password are of your BTP account credential

Client id , Client secret and Token service URL below are from XSUAA service key created earlier.

Please note don't forget to add '/oauth/token' in the Token service URL taken from XSUAA service key URL.



Until now we are good with destination creation , please check connection as well.


Now goto workflow in BAS and add destination in service task and service URL as well.

GET call in service task

Here Path would be the url to your service along with the entityset.This part will be added in the destination path. I have created a variable for same. Path along with destination should build your complete URL to service.


PUT/POST call in service task will be as below


Token URL will be same as service path, no addition '/oauth/token' required here. Workflow service will take care of adding 'XSRF-TOKEN = 'FETCH' in header of the get service call before doing put/post call to get the token and use the same in put/post call to authenticate.


 

Summerry 

We learned how we can connect a REST API in SAP cloud to connect to SAP Workflow using service Task. We learn how to create XSUAA service instance and use it to create REST API destination.

We can also use POSTMAN to trigger these APIs. That we will cover in different blog.

For more details on Workflow management please follow SAP Workflow Management .

To see more workflow related question and answers follow this link , and read other posts on the topic