No Code-Low Code Project demo for API data consumption
Customers often must interact with multiple third-party applications in order to exchange data. One of the ways to be able to interact with third party applications is through API calls.
API stands for Application Program Interface. An API is a software intermediary, that allows two applications to talk to each other. In this blogpost, I will take you through the steps, for creating a bot via SAP Intelligent RPA 2.0 using which API calls can be made, to get details of countries from a third-party application.
With SAP Intelligent RPA 2.0 and its Low-Code approach, I will show you how to leverage the SAP Intelligent RPA Cloud Studio, to create a RESTful API call to fetch the details of countries. When executed, the bot makes an API call to fetch details of all the countries and prompts for user input, to enter the name of the country and relevant details will be displayed in the message dialog.
The first step would be to login to the SAP Intelligent RPA Cloud factory, go to projects tab and create a new project.Enter the project name and description and click on create.
This will create the project and the project is opened in a new window.Under the Content tab, click on create and select Automation.
Provide the Automation name and description and click on create button. Here the name of the Automation is ‘API_Calls’. This will create an automation with empty workflow.
Let us add a custom script activity from the activity panel as the first step in the workflow. Click on Edit script and the custom script editor window opens. Add the below code in the custom script editor to make a REST API call to fetch the details of the countries.
Add the resource path of the REST API as the url. Method will be ‘GET’, as we are fetching the country details from the third-party application. Headers specify the format in which the response must be. In our case, it is ‘json’. REST API call is made when the ‘irpa_core.request.call’ is executed. Variable ‘response’ is created to store the fetched result of the API call.
Create an output parameter ‘Output’, that returns the response of the API call to the workflow.
Add a forever activity as the next step.
Within the forever loop, add ‘Open Input Dialog’ to call a dialog box, for the user to enter the name of the country for which the details are required.
Add a condition step, to check if the user has entered the country name in the dialog window. Loop is ended if the user hasn’t entered the country name in the dialog box or cancel button is clicked.
Add another custom script to check if the country name entered is a valid one. An input parameter named ‘Countries’ must be created to pass the details of the countries fetched in the step 1. Click on the edit script button and add the below code in the script editor. Add an output parameter named ‘Res’ to return the result to the workflow. If the country name is valid, the details of the desired country will be returned to the workflow. Else, ‘No results found’ will be returned.
Add another condition step, to check if the result from the previous step, is equal to ‘No results found’.
If yes, open message dialog activity is used to display the message ‘No results found’.
Else, open message dialog activity is used to display the country details ‘Alpha2Code’, ‘Capital’, ‘Region’, ‘Population’, ‘CallingCode’, and ‘Alpha3Code’.
Forever activity is added so that the user will be able to get the details of as many countries as they want, and the execution is ended when they click on the cancel button on the dialog window.
Here is the screenshot which shows the complete workflow.
Instead of ‘irpa_core.request.call’ in the custom script, ‘Call web service’ activity could also be used to make the API call. All the parameters required to make the API request can be stored in a variable in the custom script and the same can be passed to ‘Call Web service’ activity to make the API call.
Below is the screenshot of the Dialog window for the user to enter the country name.
The Automation output of Country details, if the country name is valid, will be as shown below.
Here is the project demo video.
The extracted data that is displayed can be inserted into excel, spreadsheet or to an email etc., with simple steps using SAP Intelligent RPA features with code-less experience.
The intention of this blog post is to get customers, business managers and RPA developers to get into thinking about using SAP Intelligent RPA 2.0 in numerous automation scenarios by using simple steps for achieving great results.
I hope you found this tutorial helpful. Please provide feedback in the comment section and feel free to ask any questions in the SAP Intelligent RPA Q&A area (link for reference: https://answers.sap.com/tags/73554900100800002142)