Skip to Content
Technical Articles
Author's profile photo Chaitanya Priya Puvvada

Challenge Submission – Create an API trigger,test in POSTMAN to have seamless integration in CAI.

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=dcb35ac696e7c2e29481d895482c994b’”

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/c971a39126f744788c6d87ab4c18539a.html

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.

Assigned tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Anita Pareek
      Anita Pareek

      Very nice blog...nicely written 🙂

      Author's profile photo Sankara Narayanan Raja
      Sankara Narayanan Raja

      Nice Blog in Right Time Priya 🙂

      Author's profile photo Sai Krishna Kowluri
      Sai Krishna Kowluri

      Good Work Priya.

      Author's profile photo Marco Aprea
      Marco Aprea

      Hi, Good work,  is possible see all code?

      The image not have a good quality.

      Thanks 🙂

      Author's profile photo Chaitanya Priya Puvvada
      Chaitanya Priya Puvvada
      Blog Post Author
      I have added the code snippet
      Regards,
      Priya
      Author's profile photo Marco Aprea
      Marco Aprea

      Thanks Chaitanya, is it not possible to have the zip file of the project exported from desktop studio? because i want to see all the code to study it and learn these API calls;

      Thanks a lot

      Marco 🙂

      Author's profile photo Samyuktha Sasi Sekaran
      Samyuktha Sasi Sekaran

      Very Nice blog,Priya Thanks !

      Author's profile photo Sonu Agarwal
      Sonu Agarwal

      Very Informative and Useful!

      Author's profile photo Divya Selvaraj
      Divya Selvaraj

      Nice blog. Good work and very useful!!

      Author's profile photo Raveendiran RR
      Raveendiran RR

      Very nice blog and thanks for the detail mention of the steps. We are trying the mentioned steps but failing in step # 6 and 7. The parameters are not visible and the postman request in step 7 fails with the error to provide full credentials. Please let us know how we can proceed here

       

      PS: we are using a trial account of RPA

      Thanks,

      Raveendiran RR

      Author's profile photo Chaitanya Priya Puvvada
      Chaitanya Priya Puvvada
      Blog Post Author

      Hi Raveendiran,

      You need to expose them as skills in Cloud Studio.

      I am not sure about the authorizations in Trail account.

      Please raise a ticket for the same.

      If you face any issues in implementation ,I can help you out.

      Author's profile photo Vijay Sharma
      Vijay Sharma

      Hi Chaitanya Priya Puvvada ,

      Thanks for sharing !!

      I am facing one issue. In my case i dont't have any application, just a custom step in my workflow . I have  defined the input and output structures in context and i want read the input variable in my custom method. I am trying like

      var abc = rootData.IO.Entry.itm_txt2.

      but it is giving me error as "IO.Entry is null or not an object". Can you please help to resolve this? i have posted a query on community also.

      https://answers.sap.com/questions/13077598/context-input-null-error-sap-intelligent-rpa.html

      Thanks

      Vijay

      Author's profile photo Chaitanya Priya Puvvada
      Chaitanya Priya Puvvada
      Blog Post Author

      Hi Vijay,

      I am have responded to your query  in the community.

      https://answers.sap.com/questions/13077598/context-input-null-error-sap-intelligent-rpa.html

      Author's profile photo Chaitanya Priya Puvvada
      Chaitanya Priya Puvvada
      Blog Post Author

      Vijay Sharma

      As mentioned in previous discussion,there should be an exact mapping  for the parameters.

      Please don't add user name  invocation context in the highlighted part as shown in screen shot.Please add it in input parameters.If the  invocation context is mapped correctly,the output is generated correctly.

      Make sure that in your workflow properties in Desktop studio ,you have mapped the input and output parameters correctly.

       

       

      Author's profile photo Vijay Sharma
      Vijay Sharma

      Chaitanya Priya Puvvada

      Thanks Chaitanya for response. I tried by removing Username from postman input, but still it giving the same error.

      Cloud Factory Error

      Cloud factory Log

      Author's profile photo Chaitanya Priya Puvvada
      Chaitanya Priya Puvvada
      Blog Post Author

      Which version of Desktop Studio are you using?

      With the new versions ,once the input and output parameters are mapped in workflow parameters, the code for root data is generated with underscore as shown below.

       

      For your scenario, it should generate as rootData_IO.Entry.

      Can you please check your too.