Introduction
This blog post explains "How to integrate CAI and SAP IRPA by creating an API trigger and testing the scenario in Postman" and is a submission for the
SAP Intelligent RPA Tutorial Challenge
I have taken a sample example of calling an open web service that takes the city as an input parameter and returns the weather condition.
Steps to be followed:
1. Create a project and workflow.
2. Create input and output parameters in the context of your scenario.
3. Create a workflow to consume that web service.
4. Deploy your project in CF.
5. Make the scenario as a skill to expose the input and output parameters.
6. Create an API Trigger.
7.Test in postman before integrating to CAI.
1. Create a project and workflow.
Project name: CAI_RPA_API.
Workflow Name:scWebServiceCall
Scenario Name:scWebServiceCall
2. Create input and output parameters in the context of your scenario.
Create the item names are q and APPID only since they are the names of the parameters.
3. Create a Workflow as shown below.
WebServicecall:
http://'https://api.openweathermap.org/data/2.5/weather?q=London&appid=dcb35ac696e7c2e29481d895482c9...
After successful registration to open web service call, APPID needs to be requested.

Code for the Web service call.
GLOBAL.step({ Call_a_web_service: function(ev, sc, st) {
var rootData = sc.data;
ctx.workflow('scWebServiceCall', 'ddb02102-30f1-4141-bc4f-94263b1443ee') ;
var urlBis = 'https://api.openweathermap.org/data/2.5/weather?q='+rootData.myData.wsParam.q +"&appid=" + rootData.myData.wsParam.APPID;
ctx.log(' urlBis : ' + urlBis);
ctx.ajax.call({
url: urlBis,
method: e.ajax.method.get,
data: "",
contentType: e.ajax.content.json,
success: function(res, status, xhr) {
sc.localData.output = res;
rootData.myData.wsOutput.weatherResult = res.weather[0].description;
ctx.log(' ctx.ajax.call success : ' + res.weather[0].description);
ctx.log(' ctx.ajax.call success from wsoutput : ' + rootData.myData.wsOutput.weatherResult);
sc.endStep(); // Write_log
return;
},
error: function(res) {
ctx.log(' ctx.ajax.call error: ' + res);
sc.endStep();
return;
}
});
}});

Build the project .
4. Deploy the project in Cloud Factory.
Refer to the below link to deploy the project in the Cloud factory.
https://help.sap.com/viewer/8ecea00c1f854fd0a433c4aef5da1ea2/Cloud/en-US/c971a39126f744788c6d87ab4c...
5. Navigate to Cloud Studio and mark your scenario as a skill
to expose the input and output parameters.
6. Create an API trigger after the successful deployment of the package.
A pop up appears to enter the name of the API trigger and the scenario name.

Click on Create.

Click on Copy and the API trigger is created successfully.
Enable the package to test the API trigger.
7.Test API Trigger in POSTMAN.
Ask your administrator to provide the following information
- Client ID.
- Client credentials.Access Token URL: Authentication URL + /oauth/token at the end.
Create a POST request in POSTMAN with the below mapping.
Go to the authentication tab, select OAuth 2.0.
Click “Get New Access Token” and enter the information from the first point (Client ID, Client Credentials and Access Token URL) in the dialog.
You need to add /oauth/token at the end of the Access Token URL.
Click on Use Token. This token is used to access the API trigger.
Once the Use token is clicked an extra value called authorization is added to the header.

Enter the body of the request as below.
Enter the value for the input parameters .
Click on Send to get the output.
The output triggers the running instance in the Cloud factory.
Open the Desktop Agent to run the project in unattended mode.

The output of the API trigger can be seen in JOBS after successful execution.
Conclusion:
The API trigger is tested and works perfectly from POSTMAN.
The endpoint URL is ready and can be consumed in any integration scenario like CAI etc.