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: 
ajithgokul10
Discoverer
0 Kudos

Introduction


Automation of business process through APIs is a powerful approach that allows integration with SBPA tenant, enabling you to interact with and manipulate data programmatically.


Deploying an automation BOT as a web service API involves making your automation functionality accessible over the internet so that other systems or users can interact with it by the API calls. These API calls can be executed from 3rd Party API tools like POSTMAN.



Why are we triggering BOT through API?


Triggering a bot through APIs offers several advantages. Bots are software applications designed to automate tasks, interact with users, and perform actions based on predefined rules or AI capabilities. When we trigger a bot through APIs, it means we are initiating its execution or instructing it to perform specific tasks programmatically using API calls.


APIs allow seamless integration between bots and other applications, services, or databases. By triggering the bot through APIs, we can connect it with various platforms, enabling the bot to access and exchange data. Through APIs, we can initiate multiple instances of the bot simultaneously. This feature helps distribute workload and process tasks in parallel, enhancing performance and scalability.


By triggering bots through APIs, we can maintain centralized control and monitoring. API calls can be logged, audited, and tracked, providing a clear view of the bot's activity.


Use case:


In this use case we are going to see creating Sales order scenario in SAP S/4H System. This UI Automation scenario will be triggered from API calls via POSTMAN.


Pre-requisite:




  • A deployable Bot,

  • Access to the BTP Cockpit,

  • Postman application.


        Then these following steps need to be performed sequentially,




  •   Deploy the Bot,

  •   Create automation trigger and expose API endpoint,

  •   Configuration of BTP Cockpit,

  •   Configuration of POSTMAN.


1)Deploying SBPA Bot:




  1. First click release button at the top right corner to release the bot,





  1. Give comment, then click release,





  1. Once it is released, we can be able to see the Deploy button on the right corner. Now click on deploy,





  1. Click next and deploy.





  1. Once the bot deployed, navigate to the monitor tab to add automation trigger. Here click on the Go to Monitor > Triggers button.





  1. Select trigger type as API and click next,





  1. Now, provide some name for the trigger, choose the automation flow which executes once the API is called





  1. Now we will get the HTTP Method, URL and input Payload structure.



                                                Sample endpoint IMG 1.8


Now we have successfully deployed the Bot and created the Automation trigger.






2)Configuration of BTP Cockpit:


1.Navigate to the BTP Cockpit centre->Services and Instances page,


Create an instance of the SAP Build Process Automation service, using the standard plan,





  1. Once you created, wait till the status turn into green





  1. Now click on the three dots to add a Service Key. Provide service key name and click create,





  1. Once the service key created, Click view to see those credentials





  1. We are going to use OAuth authentication like all other BTP services. OAuth authenticates the client application not the user. Please note down the following credentials in notepad these will be used in the following steps,



  • Authentication URL,

  • Client ID,

  • Client Secret







3)Configuration of POSTMAN,




  1. Open POSTMAN application in your desktop, create a new collection and add a request





  1. Under Authorization tab, select type as OAuth 2.0 and select Request Headers in the drop down.





  1. Now provide the following credentials on each textbox,



  • Access Token URL

  • Client ID

  • Client Secret


Choose Client Authentication as a Send as a Basic Auth header.


Give the access token URL as per the following format.


<Authentication URL>/OAuth/token





  1. Now click on Get New Access Token





  1. A New Token will be generated, Use this token for further authorizations





  1. Under Header tab create a new header irpa-api-key





  1. Go to the tenant, under Settings tab click API Keys->Add API Key.



      8. Provide API Key name and click Next



 9.Click create,



10.Note down the API Key, it will be shown only once.



 

Finally Add the generated API key to POSTMAN.


 

Execution


Now the Bot is ready to execute,


Give the payload as per the Input schema generated and click Send.



for a successful API call, we will get the response as 201 Created and the Job ID will be shown in the body. Which means the job has been added in the queue for execution.


To check the execution status of the bot, navigate to tenant and click Monitor->Automation Jobs,



Note:




  • The desktop agent should be in Unattended Mode,

  • While giving the JSON Payload data, we must maintain exact naming conventions and datatypes.


Conclusion:


By using this method, we can trigger a job to automate SAP and Non-SAP application in asynchronous way.


I hope this blog addressed what you’re looking for,


Let me know in comments if you have any queries.


Thanks,


Ajith