Skip to Content
Product Information
Author's profile photo Peter Engel

SAP Process Automation: How to test the API trigger with postman

In my last blog post I explained how to design a process with an API based trigger. Many of you are curious about how you can test this new feature.

I will describe the technical implementation and the testing procedure in this blog post.

Technical prerequisite

To use the API trigger you need a service instance with a service key in your sub-account where you are using SAP Process Automation.

Service instance

In your subaccount a service instance should be already exist. You can find the service instance in the Instances and Subscriptions section.

If you have no service instance please create a service instance by following the guided procedure after the click on the Create button.

Service key

If you have already the service instance or just created it, check if you have also created a service key.

If not please create a service key using the icon with three dots.

Using Postman

All information to call the API trigger are available in the service key. Therefor open the service key and use the following information:

  • endpoints api url
  • clientid
  • clientsecret
  • uaa url

Create a new post request in postman with the endpoints api url and add /workflow/rest/v1/workflow-instances to the url.

To get a token select Client Credentials as Grant Type, use the uaa url plus /oauth/token for the Access Token URL and fill in Client ID and the Client Secret.

For the Client Authentication use “Send as Basic Auth header”.

After maintaining the data click on Get New Access Token and use the token.

After this you switch to the Body tab and maintain the payload.

You can find the definition ID in the Monitoring section of SAP Process Automation. Go there to Manage and then to Processes and Workflows.

Copy the ID and paste the value into the payload. In the “context” of your payload you have to maintain all the fields you need.

Now you can execute the post request and you successfully create your first process instance via the API trigger.

Conclusion

You learned now how to test the API trigger in SAP Process Automation and you can start now integrate processes designed in SAP Process Automation in your applications.

Next Steps

You are curious now but do not how to start? Try it out now using our Free Tier offering.

You are interested in the bigger picture of LCNC?

To see LCNC in action, check out the SAP Low-Code/No-Code Learning Journey – designed to increase low-code/no-code skills and teach citizen developers the basic concepts of software development including SAP AppGyver, SAP Process Automation, and SAP Work Zone and learn how to build mobile apps for free. Check out LCNC and plus much more free learning for developers at SAP Learning site.

 

For more information on SAP Process Automation, please refer to the following sources:

 

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Antonio Maradiaga
      Antonio Maradiaga

      In case anyone is interested in a Postman collection and environment that can help you get started.... see the examples below. The collection includes OAuth 2.0 authentication. All you will need to update is the Postman environment details.

      sample.postman_collection.json

      {
      	"info": {
      		"_postman_id": "56c8577c-c9c9-4e6f-b08f-bd46892efe11",
      		"name": "Process Automation - Trigger API",
      		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
      		"_exporter_id": "372207"
      	},
      	"item": [
      		{
      			"name": "Trigger process",
      			"request": {
      				"method": "POST",
      				"header": [],
      				"body": {
      					"mode": "raw",
      					"raw": "{\n    \"definitionId\": \"region.yourinstance-spa.triggerapitest.myprocess\",\n    \"context\": {\n        \"field_1\": \"1007895\",\n        \"field_2\": \"Penn and Teller show\",\n        \"field_3\": 20\n    }\n}",
      					"options": {
      						"raw": {
      							"language": "json"
      						}
      					}
      				},
      				"url": {
      					"raw": "{{endpoint.api}}/workflow/rest/v1/workflow-instances",
      					"host": [
      						"{{endpoint.api}}"
      					],
      					"path": [
      						"workflow",
      						"rest",
      						"v1",
      						"workflow-instances"
      					]
      				}
      			},
      			"response": []
      		}
      	],
      	"auth": {
      		"type": "oauth2",
      		"oauth2": [
      			{
      				"key": "clientSecret",
      				"value": "{{uaa.clientsecret}}",
      				"type": "string"
      			},
      			{
      				"key": "clientId",
      				"value": "{{uaa.clientid}}",
      				"type": "string"
      			},
      			{
      				"key": "accessTokenUrl",
      				"value": "{{uaa.url}}/oauth/token",
      				"type": "string"
      			},
      			{
      				"key": "tokenName",
      				"value": "spa-api-token",
      				"type": "string"
      			},
      			{
      				"key": "challengeAlgorithm",
      				"value": "S256",
      				"type": "string"
      			},
      			{
      				"key": "grant_type",
      				"value": "client_credentials",
      				"type": "string"
      			},
      			{
      				"key": "addTokenTo",
      				"value": "header",
      				"type": "string"
      			},
      			{
      				"key": "client_authentication",
      				"value": "header",
      				"type": "string"
      			}
      		]
      	},
      	"event": [
      		{
      			"listen": "prerequest",
      			"script": {
      				"type": "text/javascript",
      				"exec": [
      					""
      				]
      			}
      		},
      		{
      			"listen": "test",
      			"script": {
      				"type": "text/javascript",
      				"exec": [
      					""
      				]
      			}
      		}
      	]
      }

       

      sample.postman_environment.json

      {
      	"id": "e051fa16-0620-4d86-a9dd-0e8aed9047d7",
      	"name": "process-automation-region-sk",
      	"values": [
      		{
      			"key": "endpoint.api",
      			"value": "https://the-endpoint-api-url-in-sk.cfapps.region.hana.ondemand.com",
      			"type": "default",
      			"enabled": true
      		},
      		{
      			"key": "uaa.clientid",
      			"value": "sb-btc564fq-u6xo-8063-h6cu-58ws3538201t!v808583|xsuaa!q467428",
      			"type": "default",
      			"enabled": true
      		},
      		{
      			"key": "uaa.clientsecret",
      			"value": "mEf2s0ldQbaqhVH/vmriBjBSO/Q=",
      			"type": "default",
      			"enabled": true
      		},
      		{
      			"key": "uaa.url",
      			"value": "https://yourinstance-spa.authentication.region.hana.ondemand.com",
      			"type": "default",
      			"enabled": true
      		}
      	],
      	"_postman_variable_scope": "environment",
      	"_postman_exported_at": "2022-09-01T19:54:10.857Z",
      	"_postman_exported_using": "Postman/9.29.1"
      }
      Author's profile photo Raghuraman Ramakrishnan
      Raghuraman Ramakrishnan

      Great Blog Peter Engel . Thank you Antonio Maradiaga for thoughtfully sharing the postman collections

      Author's profile photo Nils Mentzel
      Nils Mentzel

      Hello, is it possible to use a service instance of the service "ABAP environment" or any other environment, or is it only possible to generate a valid service key with a service instance of the type "SAP Process Automation"?

      I'm asking this because I only have an Instance of the type "ABAP environment" installed on my subaccount and when I try to set up one for Process Automation, it won't let me, for the reason that I am subscribed to it already.