Create Action Project for simple CAP Service in SAP Build Actions
- to modify the generated OpenAPI specification of a CAP Service
- to create an action project based on the API specification
- to test API using a BTP destination
- to release and publish the action project to be consumed in a process of SAP Build Process Automation
Prerequisites
- Access to a SAP BTP tenant with SAP Build Process Automation
- Step 1
You will generate the openAPI specification for the service used to create the Action project in SAP Build.
-
Navigate back to the Business Application Studio. Open your CAP project and run the following command in the Terminal window:
Shell / BashCopycds compile srv --service all -o docs --to openapi -
In the subfolder
docsfolder, open the filesap_build_cap_sample_library.openapi3.json.
-
- Step 2
The generated OpenAPI specification needs some manual changes.
-
Update the following paths definitions (just replace the lines in the generated file):
JSONCopy"/addQuotes(value='{value}')": { "get": { "summary": "addQuotes", "tags": [ "Service Operations" ], "parameters": [ { "required": true, "in": "path", "name": "value", "description": "String value needs to be enclosed in single quotes", "schema": { "type": "string", "default": "" } } ], "responses": {JSONCopy"/getListOfTodos()": {JSONCopy"/toInteger(value='{value}')": { "get": { "summary": "toInteger", "tags": [ "Service Operations" ], "parameters": [ { "required": true, "in": "path", "name": "value", "description": "String value needs to be enclosed in single quotes", "schema": { "type": "string", "default": "" } } ], "responses": {JSONCopy"/toNumber(value='{value}')": { "get": { "summary": "toNumber", "tags": [ "Service Operations" ], "parameters": [ { "required": true, "in": "path", "name": "value", "description": "String value needs to be enclosed in single quotes", "schema": { "type": "string", "default": "" } } ], "responses": {JSONCopy"/toStr(value={value})": { "get": { "summary": "toString", "tags": [ "Service Operations" ], "parameters": [ { "required": true, "in": "path", "name": "value", "schema": { "anyOf": [ { "type": "number", "format": "double,null" }, { "type": "string" } ], "example": 3.14, "nullable": true, "default": "" } } ], "responses": { -
Add required: true for components/schemas schema definition of DataListArray.
JSONCopy"sap_build_cap_sample_library.DataListArray": { "title": "DataListArray", "type": "object", "properties": { "responseArray": { "type": "array", "required": true, "items": { "$ref": "#/components/schemas/sap_build_cap_sample_library.DataList" } -
Select the file content Ctrl-a in the editor and copy to your clipboard Ctrl-c.
-
Create a new file called demo.json in a local folder of your desktop.
-
Open the file, paste the content and save the file. You will use the file later to create the Action Project.
Here below, a screenshot with parts how the file will look like:

-
- Step 3
-
Open SAP Build Lobby, under Connectors, select Actions.

-
Choose Create.

-
In the Choose an API Source popup, under API Specification, select Upload API Specification.

-
Drag and drop or click Browse Files to upload open specification file downloaded in step above.
-
Choose Next.

-
In the Create an Action project popup:
- Specify the name
CAP Sample Actions - Click Create

- Specify the name
-
Once the action project is created, the action editor will automatically open. In the popup select all actions from the list, click Add.

Your Action Project will contain the actions for the CAP service.

Why would you test the actions in the Action Editor?
-
- Step 4
You can test the execution of your action in the Action Editor.
-
Select
listToStringfrom the list, the action has input parameters -
Select Tab Test
-
Choose Destination Demo_CAP_Sample_Library
-
enter id
1 -
enter title
task1 -
enter field
id -
Click Test

In the Test you can specify only one value for a list. In the Response View you can see that the values are converted to a string (with more than one value they will be comma separated). You can also try title as field and check the result.
-
-
Select
get list of Todosfrom the list, click Output tab to check that the array is marked as required withred asterix
-
Select Test tab and click Test

-
You can test the other actions (optional)
-
Select toInteger from the list, enter value
10and click Test -
Select toNumber from the list, enter value
10.9and click Test -
Select addQuotes from the list, enter value
abcand click Test
-
-
- Step 5
To be able to use the Actions in a Process, you have to release and publish the Action Project.
-
Click Release

-
Enter release information, click Release

-
Click Publish to Library

-