SAP Build Process Automation: Consume an OData API as Actions using a Destination
Call an OData API from SAP Build Process Automation by using Actions created from a Destination.
In SAP Build, Actions are connectors that enable simplified, reusable consumption of APIs. Actions are consumable in SAP Build Process automation (Process, Automations, Forms) and in future planned to be consumable in SAP Build Apps.
- SAP Build Lobby has a new improved experience utilizing a side navigation panel and Actions are available under Connectors node. Action Projects are not listed under Lobby anymore, rather under the Actions tab.
- Actions can now be created directly based on SAP BTP Destinations for OData APIs. Previously, it was necessary to upload either an OpenAPI JSON or OData EDMX/XML specification file.
Sample Use Case
Consume Northwind OData API in a Process via Actions using a SAP BTP Destination.
In this sample use case, focus is on showing the steps to consume an API in a Process and not on demonstrating customization/simplification features of Actions or Process.
Part 1: Create, Test and Publish an Action
Create a Destination in the same sub-account of SAP BTP where the Process Automation is subscribed.
- Use the Northwind OData URL: https://services.odata.org/northwind/northwind.svc/
- Maintain Destination Properties:
- Maintain Authentication as NoAuthentication. After creation the destination looks like below
Create action from destination
- In SAP Build Lobby, under Connectors node choose Actions. Click on Create.
- Choose OData Destinations tile, choose the destination. In case there is only one destination it gets auto selected.
- Choose next when the screen displays all the available entities and methods of the OData API. Behind the scenes “/$metadata” is appended to the destination URL to fetch this information.
- Update the Project name and description then click Create.
- This launches a new tab called Actions Editor. Here choose the methods that you would like to publish as Actions. For example, choose GET for /Customers under Customers Group. Click Add.
Test, release and publish actions
- Inputs and Outputs can be customized or simplified as needed but in this simple example proceed without making any changes.
- Switch to the test Tab to test the Action. Notice that the destination is pre selected as the Action was created based on a Destination.
- Click on Test. A successful 200:OK response from the Northwind OData API is now shown at the bottom of the screen.
- Now click on the Release button at the top right and then click on Publish. “Release” creates a non modifiable version of the Action and “Publish” publishes the Action into SAP Build library from where it can be consumed in different Build Artifacts.
Part 2: Consume the Action in SAP Build Process Automation
Destination needs to be made accessible in SAP Build Process Automation.
- In SAP Build Lobby click on Control Tower node in left pane > Select Destinations tile
- New Destination > Select Northwind destination that was created as part of 1st step > click on Add
Create a Process to call the action and view action response
- Lobby -> Create -> Build an Automated Process -> Business Process -> Enter Project name and Description -> Create.
- Create Process -> Enter Name -> Create
- Click on + icon in the middle of the process -> Actions -> Browse library
- Search for the Action “Get entities from Customers” and click on Add
- Select the Added Action in the Process, create a destination variable with any name, for example “Northwind_dest”. This would be used during deployment of the process to link to an actual destination. A destination variable enables linking different destinations in different landscapes ( Dev, Test, Prod) without changing the Process.
Deploy the Process
- Click on Save and then Release.
- Click on Deploy > Next in Overview Dialog > Choose Northwind destination in the Runtime Variables Dialog then next > Deploy
Test the Deployed Process
- A simple way to test the Process is to start a new instance and check the logs for the response received from the API.
- Click on Monitoring node in Left Pane > Process and Workflows Tile > Select the Northwind Process deployed in previous step > Click on Start New Instance button
- Ignore the input JSON, click on Start New Instance and Close button
- Click on Show Instances. Update Status filter to also show Completed Process instances
- Select the Process Instance to see the Logs and Context. If the API call was successful, the response of the API is seen in the context.
A list of Customers from the sample Northwind OData API was successfully retrieved in a Process of SAP Build Process Automation. This was achieved using the new feature of Actions creation from a destination.
Actions were intentionally underutilized in this example but they could enable simplification of the inputs, outputs, provide default values, filter data, make automatic CSRF calls and lot more but that is for subsequent Blogs.