Technical Articles
Calling SuccessFactors OData APIs via iRPA 2.0
I have been quiet impressed with SAP Intelligent RPA 2.0. With a recent customer request I got a chance to do a POC with SuccessFactors API upsert calls. Here I try to share my experience and hope it is helpful for the community.
For learning to deploy and call the automation from a SAP CAI based chatbot please read my blog post: Let’s call the iRPA bot from CAI to update SuccessFactors
If you need to use oAuth 2.0 authentication in your project please refer my blog on Using OAuth 2.O to securely call SuccessFactors OData APIs from iRPA 2.0
Step 1: Setup of iRPA
SAP Intelligent RPA is available via the SAP Business Technology Platform (BTP). You must create and configure an SAP Intelligent RPA tenant in the SAP BTP to get access to the SAP Intelligent Robotic Process Automation Factory. You can find the detailed steps at https://help.sap.com/viewer/6b9c8e86a0be43539b670de962834562/LATEST/en-US/17bda7e650b847679c3f8c2c11ada29e.html
The booster tool eases the creation of your subaccount and your subscription to SAP Intelligent RPA.
Once you have launched it, the booster automatically performs the following steps:
- Creating Subaccount
- Enabling Cloud Foundry
- Assigning Service Quotas
- Creating Space
- Subscribing to SaaS Applications
- Adding Cloud Foundry Users
- Creating Service Instances
- Creating Role Collection
- Assigning Role Collection
Once installed you can directly launch the Cloud Factory application instance from the subaccount:
After this you will need to install the on premise component i.e. the desktop agent using the industry standard Windows MSI installer. You will find the latest version of desktop agent at the SAP Software center:
Software Center
Once installed you will need to register the desktop agent to the cloud factory studio for iRPA. You can do this using the steps defined at: https://help.sap.com/viewer/6b9c8e86a0be43539b670de962834562/LATEST/en-US/84089a65b7274effb907df3dc54ab3e1.html
Now you are ready to create new Automation.
Step 2: Create Automation
Define the input parameter as cred of type String which we will bind to the encoded string from the previous step. Also we define output parameter as token of type Any
Add the following custom script to the step
async function fetchToken() {
const token = {
resolveBodyOnly : false,
method: 'GET',
url: 'https://apisalesdemo4.successfactors.com/odata/v2/RBPRole',
headers: {
'Accept' : 'application/json',
'Content-Type': 'application/json',
'Authorization' : 'Basic ' + cred,
'x-csrf-token': 'fetch'
}
};
try {
const response = await irpa_core.request.call(token);
return response;
} catch (error) {
const csrfToken = error.response.headers['x-csrf-token'];
return error;
}
}
let response = await fetchToken();
return response.headers;
csrf_token of type String bound to [0] value retrieved previously
We use the custom script to formulate the POST request. In the POST request we use the upsert api to create a new role in RBP in the SuccessFactors instance. We use the payload of content type application/json in the script:
var i = 0;
var temp ="";
var cookieField ="";
if(cookie!=""){
for(i=0;i<cookie.length-1;i++)
{
temp = cookie[i].split(";");
cookieField = cookieField + temp[0] + "; ";
}
temp = cookie[i].split(";");
cookieField = cookieField + temp[0];
}
var data = {
"__metadata": {
"uri": "RBPRole",
"type": "SFOData.RBPRole"
},
"roleDesc": "test123",
"roleName": "test123"
};
var payload = {
resolveBodyOnly : true,
method: 'POST',
url: 'https://apisalesdemo4.successfactors.com/odata/v2/upsert',
headers: {
'Authorization': 'Basic '+ cred,
'Cookie' : cookieField,
'Content-Type': 'application/json',
'x-csrf-token' : csrf_token
},
ignoreClientCertificate: true,
body: JSON.stringify(data)
};
return payload;
Step 3: Run the automation
Now we can test the automation in our environment passing the user credentials for the SuccessFactors instance
FYI:
Your endpoint URLs for calling the SuccessFactors OData APIs depend on the data center hosting your SAP SuccessFactors instance. Your SAP SuccessFactors support representative can tell you the data center location to use for your instance. For a list of the API Endpoint URL for the SAP SuccessFactors environments, see About HXM Suite OData APIs.
I hope this helps you as well to build your automations in iRPA 2.0
For learning to deploy and call the automation from a SAP CAI based chatbot please read my blog post: Let’s call the iRPA bot from CAI
Thanks @Divya Tiwari for the detailed blog, I am working on the Odata report in Business ByDesign.
Regards
Janarthanan
Hi Divya!
First all, congrats for article. If you can help me with my problem.
My goal is to connect with SF through a destination if possible and get the user data, type code, name, email etc that is in Success Factor.
I will try connect with SF using SAP BTP Destination
However, when trying to make the connection with the destination, this error is returned.
Thanks
Hi Fernando Meregali Xavier,
it's nice to meet you here, actually we are at the same point, can you let us know if you can crack this or not. This will help us to move forward.
Thanks and regards,
Narenthiran Annamalai.
Hi Narenthiran and Fernando Meregali Xavier,
The time I had written the blog there was not complete support for destination consumption.
I am yet to experiment with it. I would suggest that you can start with exploring the following blog:
SAP PROCESS AUTOMATON ( IRPA/SPA ) Consume API Directly for Create/Read/Update/Delete Operations
I hope this one helps.
Regards,
Divya
Hi Divya,
I am not able to write expression ( step1.cred ) in input parameter cred.
Please please help me on this.
