Skip to Content

Test the Business Rules API from SAP API Business Hub

0 %
Test the Business Rules API from SAP API Business Hub

Test the Business Rules API from SAP API Business Hub

March 8, 2021
Created by
September 19, 2019
Use SAP API Business Hub to test and run the business rules service API to see how business rules service can be consumed from a custom application.

You will learn

  • How to use Business Rules APIs
  • How to test Business Rules project
QR code


Generally, after a rule service is deployed to a custom application, the rule service should be invoked to implement the decision logic. In this tutorial, we will simulate the rule service invocation by invoking the rule service from SAP API Business Hub.

Business Rules REST APIs are available on SAP API Business Hub which lets you execute rules from custom applications and external REST Clients. Since these APIs are based on OAuth 2.0 authorization, you need the client credentials to access them. You get the client credentials from the service key of the business rules service instance.

Step 1: Log on to SAP API Business Hub
  1. Log on to SAP API Business Hub

    API Hub Homepage
  2. In the search bar, search for Business rules. From the search results, select the API package for SAP Business Rules Service.

    Search bar
  3. Choose the Rule Execution API for Cloud Foundry tile of Version v2.

    Rule Execution API tile
Log on to answer question
Step 2: Determine the service key parameters

Service key parameters are required to configure the environment in SAP API Business Hub.

  1. Log on to SAP BTP Cockpit.

  2. Choose Enter your trial account.

    Log on screen
  3. Choose your trial subaccount.


    Choose your space.

    In the following screenshot, the name of the space is dev. Space name can also be a custom name that you have provided.

    dev space
  4. From the navigation menu, choose Instances.

    service instances
  5. In the wm_business-rules service instance, choose the actions button, and then choose Create Service Key.

    business rules service instance
  6. In the New Service Key window, provide the name of the service key as business-rules or any name of your choice, and then choose Create.

    service key creation

    Service key of wm_business-rules service instance will be created.

  7. Choose the service key.

    Service key name
  8. From the service key, note the following parameters required for configuring the environment:

    • clientid
    • clientsecret
    • url
    service key parameters
Log on to answer question
Step 3: Configure the environment

You need to configure the environment to link it to the business rules project which you have created in Manage Rule Projects application. Since Business Rules APIs are based on OAuth 2.0 authentication, you need to provide the client credentials determined in step 2.

  1. Choose Configure Environments.

    Configure environment
  2. In the Configure Environments window, provide the following details:

    Field Name Value
    Display Name for Environments EU10
    Client Id clientid
    Secret clientsecret
    tokenurl url

Enter the token URL without https://. For example, if the token URL in the service key is https://<trial ID>, then enter <trial ID>

Configure environment

Then, choose Save.

Configure environment
Log on to answer question
Step 4: Invoke a rule service
  1. Select Invoke a Rule Service API and then choose /v2/workingset-rule-services. Then choose Try out to execute the API.

    Configure environment
  2. Fetch the rule service ID from Manage Rule Projects application. This is required for the API JSON payload.

    In the Rule services tab, choose Settings icon.

    Configure environment

    Select ID and choose OK.

    Configure environment

    Copy the ID from the rule service.

    Configure environment
  3. Paste the rule service ID in place of <rule-service-ID> in the following JSON payload and copy it to the body of the API:

      "RuleServiceId": "<rule-service-ID>",
      "Vocabulary": [
          "Employee": {
            "IsFullTimeEmployee": true,
            "countryofCompany": "USA",
            "jobTitle": "Engineer II",
             "company": "2000"

    Then choose Execute.

    Configure environment
Log on to answer question
Step 5: Observe the API response

You can view the equipment assigned to the employee in the response body of the API.

Configure environment
How do you determine the OAuth 2.0 parameters required for configuring the environment on SAP API Business Hub?

Next Steps

Back to top