Execute in Postman

Print Friendly, PDF & Email

◷ Reading Time: 4 minutes

It requires an API development environment to test the API. In this example, Postman was used.

Get the Bearer Token

You will get the Access Token

The token can also be taken from the Test Run result of the FlexRule Server workbench instead of using the above URL.

Test the Service URL

With the above access token, you can test the Service URL

Request

The request should have the following properties:

  • Method
  • Service URL
  • Authorization (Type, Token)
  • Body (Input text/ object, Content-Type)
  • Header (Authorization, Content-Type)

Now let’s discuss these in detail.

Method:’ POST

Service URL:’ <Working Service Url of the package>

Authorization:’

  • Type: ‘Bearer Token’
  • Token: <Access Token>

Body:’<Your input JSON object>

Inputs are a set of name-value pairs. Name is the name of the parameter, and Value is the value of the parameter. Inputs must be provided in a name/value format as the above Request specification indicates.

{ 
  "inputs": [
            {
              "name": "person",
              "value": {
                "Age":20
              }
            }
        ]
}

Headers:’

  • Authorization: <Type and Token> (This will be autofilled in Postman, after adding Authorization Type and Token)
  • Content-Type: application/json (This will be autofilled in Postman, after adding Body by selecting JSON (application/json))

Response

Once you send the Request, the Response can be seen as follows:

Examples

Let’s deploy some logic as a service and then start calling it.

In the first step, we call the service with ?async=true:

http://localhost:9000/api/services/execute/agepackage/1/person growing state?async=true

As a result, the location indicating where the result can be retrieved is returned. Please note the result code is 202, rather than 200 for a normal call.

Now we can post a request to the location and retrieve the result:

Workflow Example

{
    "EnableFullLog":true,
    "CorrelationId": null, 
    "Actor": null,
     
    "inputs":[
 {
   "Name": "InputNextNumber",
   "Value": 0 
 }
],
    "UseEarliestVersion": true,
    "UseLatestVersion":true,
    "ServiceKey": "WorkflowWorkflowtest",
    "ServiceVersion": "1",
     
    "Workflow": {
      "WorkflowInstanceId": "fd029cd2-f1b4-e911-a260-b46bfc9f7ca6",
      "QueryTasks": false,
      "ResumeInfo": {
           "Title": "GetInput",
           "Category": null,
           "Outcome": null
       } 
    }
}

When you test using Postman, “QueryTasks” should be false.

Video Tutorial

Download the Sample

Use the attachment (FlexRule-Sample-Agepackage.zip) at the end of the page to download the sample package to upload and test.

Updated on October 22, 2019

Article Attachments

Was this article helpful?

Related Articles