How to Create Calculation Logic as REST API for Postman Request

Creating a calculation logic as a REST API for Postman Request consists of these steps: 

Create Calculation Logic with Input Parameters

Le'ts assume that we'll send the following body request which is needed to pass the CustomerID and ProductID:

{
    "data": {
        "CustomerID": "111980",
        "ProductID": "1504795"
    }
}

Now execute a calculation logic which returns some expected data and make it receive the request parameter, e.g ProductID, using api.input("ProductID").

Request Logic with POSTMAN

At first, encode with Base64 the combined string with this format: partition_name/username:password

Assuming that you already have Postman, let's create a new POST request with the below configuration:

Endpointhttps://staging.pricefx.eu/pricefx/partition_name/formulamanager.executeformula/logic_name
Authorization typeNo Auth
Headers

Add two new pairs:

  • Authorization: Basic BASED_64_ENCODED_CREDENTIALS
  • Content-Type: application/json
Request bodyThe above JSON request


The response result will look like this:

{
    "response": {
        "node": "node1",
        "csrfToken": "1dtkww9y7hg8vs2qnh4u9ct0t",
        "data": [
            {
                "resultName": ...,
                "resultLabel": ...,
                "result": 
            }
        ],
        "status": 0
    }
}

For more details see the API Documentation: https://qa.pricefx.eu/pricefx-api/json/master.html#!/formula/executeformula