GetBatchResults (Application-Level)

You are here:

The primary usage of this method is to perform multiple calculations with a single server request based on a set of calculation requests and return a set of calculated outputs. The method also includes support for Goal Seek calculations.

Authentication

This method requires an authentication token if the access level of the application is set to Restricted.

Request

Target Endpoint

POST /Api/Applications/GetBatchResults

Parameters

Property Name

Type

Is Required?

Description

ApplicationKey String Required The application key, corresponding to your specific web service application. This constitutes the identifier for the requested resource.
UserName String Optional Username of the user requesting the batch calculation.
SessionId String Optional A session identifier, to be utilized in conjunction with the /OpenDedicatedSessionand /CloseDedicatedSession methods. Details outlined in those sections.
Requests Array of Object

 

JSON Schema:

[

{

Id: 1,

Request: CalculationSetobject

},

{

Id: 2,

Request: CalculationSetobject

}

]

Required Collection of calculation requests included in the request. CalculationSet Object properties can be found below.

 

CalculationSet Members

Property Name

Type

Is Required?

Description

Id Integer Required An identifier that you can subsequently use to tie your original requests to your responses (since you will be getting a set). It is best to ensure that these are unique within a given request in order to best match your requests to your responses.
Inputs Array of Object

 

JSON Schema:

Setting a single cell:

 

{
Ref: “Sheet1!A5”,

Value: [

[

{

Value: “10”

}

]

]

}

Required Collection of cells or references that will be set as part of the request to the calculation engine.

 

The property name should correspond to a cell reference (e.g. WorksheetA!$A$4) or a named range.

Outputs Array of String:

 

[

“CellE”,

“CellF”,

“CellG”

]

Required A list of outputs to be retrieved after calculations are done and sent back in the respond.

 

Each item should correspond to a cell reference (e.g. WorksheetA!$A$4) or a named range.

GoalSeek Object Optional GoalSeek property contains input parameters of goal seek feature.

Object properties can be found under the GetResult method.

 

Request Sample (Restricted)

The sample below is a simple request to the GetBatchResults method for a restricted application, clearly designated by the bearer token in the authorization header. The token was retrieved using an authentication request. The process of retrieving an access token is documented here.

Headers

POST /Api/Applications/GetBatchResults HTTP/1.1
Authorization: Bearer Do3l_2l3uLdmYX76u-BufLzuuhFPOE-nRZDyU0adiFk1
Content-Type: application/json
Host: dev7.pagos.com

Body (formatted)

{
   "ApplicationKey": "b2078bc678b94f40b6a5793009e56594",
       "Requests": [
             {
               "Id": 0,
                "Request": {
                   "Inputs": [
                        {
                           "Ref": "InitialInvestment",
                             "Value": [
                                       [
                                         {
                                              "Type": "",
                                              "Value": "1000000",
                                              "Format": "",
                                              "Text": ""
                                         }
                                        ]
                                       ]
                                  },
                                {
                                  "Ref": "YearTwoInvestment",
                                   "Value": [
                                               [
                                                  {
                                                       "Type": "",
                                                       "Value": "50000",
                                                       "Format": "",
                                                       "Text": ""
                                                }
                                            ]
                                        ]
                                  }
                           ],
                           "Outputs": [
                                  "scen2CleanShare"
                           ],
                           "GoalSeek": {
                                  "Enabled": true,
                                  "TargetRef": "oMacroSc21",
                                  "ChangingRef": "scen2CleanShare",
                                  "TargetValue": 0,
                                  "MaxIterations": 100,
                                  "MaxChange": 0.001
                           }
                    }
             },
             {
                    "Id": 1,
                    "Request": {
                           "Inputs": [
                                  {
                                        "Ref": "InitialInvestment",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "",
                                                            "Value": "1000000",
                                                            "Format": "",
                                                            "Text": ""
                                                      }
                                               ]
                                        ]
                                  },
                                  {
                                        "Ref": "YearTwoInvestment",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "",
                                                            "Value": "50000",
                                                            "Format": "",
                                                            "Text": ""
                                                      }
                                               ]
                                        ]
                                  }
                           ],
                           "Outputs": [
                                  "scen2CleanShare"
                           ],
                           "GoalSeek": {
                                  "Enabled": true,
                                  "TargetRef": "oMacroSc21",
                                  "ChangingRef": "scen2CleanShare",
                                  "TargetValue": 0,
                                  "MaxIterations": 100,
                                  "MaxChange": 0.001
                           }
                    }
             },
             {
                    "Id": 2,
                    "Request": {
                           "Inputs": [
                                  {
                                        "Ref": "InitialInvestment",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "",
                                                            "Value": "1000000",
                                                            "Format": "",
                                                            "Text": ""
                                                      }
                                               ]
                                        ]
                                  },
                                  {
                                        "Ref": "YearTwoInvestment",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "",
                                                            "Value": "50000",
                                                            "Format": "",
                                                            "Text": ""
                                                      }
                                               ]
                                        ]
                                  }
                           ],
                           "Outputs": [
                                  "scen2CleanShare"
                           ],
                           "GoalSeek": {
                                  "Enabled": true,
                                  "TargetRef": "oMacroSc21",
                                  "ChangingRef": "scen2CleanShare",
                                  "TargetValue": 0,
                                  "MaxIterations": 100,
                                  "MaxChange": 0.001
                           }
                    }
             }
       ]
}

Response

Property Name

Type

Description

Success Boolean Indicated whether or not the request was successful
InvalidToken Boolean If the request is unsuccessful, indicates whether or not the failure was due to token.
Messages Array of String A list of messages, which can be used or captured for diagnostics. When requests are unsuccessful, the reason for the failure will be documented in the Messages list.
Message String When requests are unsuccessful due to calculation engine, the response of the core calculation engine will be documented here.
Responses Array of Object

 

JSON Schema:

[

{

Id: 1,

Response: CalculationResponse object

},

{

Id: 2,

Response: CalculationResponse object

}

]

Collection of calculation results. CalculationResponse Object properties can be found below.

 

CalculationResponse Parameters

Property Name

Type

Description

Success Boolean Indicated whether or not the request was successful
InvalidToken Boolean If the request is unsuccessful, indicates whether or not the failure was due to token.
Messages Array of String A list of messages, which can be used or captured for diagnostics. When requests are unsuccessful, the reason for the failure will be documented in the Messages list.
Message String When requests are unsuccessful due to calculation engine, the response of the core calculation engine will be documented here.
GoalSeek Object

 

Contains the results of the goal seek calculation.

Object properties can be found under the GetResult method.

Outputs Array of Object

 

JSON Schema:

single cell:

 

{
Ref: “Sheet1!A5”,

Value: [

[

{

Value: “10”

}

]

]

}

Collection of cells or references that are requested from the server.

 

The property name will correspond to a cell reference (e.g. WorksheetA!$A$4) or a named range.

Response Sample (Success)

Headers

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Content-Type: application/json; charset=utf-8

Body (formatted)

{
       "Message": null,
       "Responses": [
             {
                    "Id": 0,
                    "Response": {
                           "Message": null,
                           "GoalSeek": {
                                  "Success": true,
                                  "ChangingFormat": "0.00%",
                                  "ChangingValue": "0.00199789502620697",
                                  "TargetFormat": "\"$\"#,##0",
                                  "TargetText": "$0",
                                  "TargetValue": "0.000310385832563043"
                           },
                           "Outputs": [
                                  {
                                       "Ref": "scen2CleanShare",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "Number",
                                                            "Value": "0.00199789502620697",
                                                            "Format": "0.00%",
                                                            "Text": "0.20%"
                                                      }
                                               ]
                                        ]
                                  }
                           ],
                           "Success": true,
                           "InvalidToken": false,
                           "Messages": []
                    }
             },
             {
                    "Id": 1,
                    "Response": {
                           "Message": null,
                           "GoalSeek": {
                                  "Success": true,
                                  "ChangingFormat": "0.00%",
                                  "ChangingValue": "0.00390082712173462",
                                  "TargetFormat": "\"$\"#,##0",
                                  "TargetText": "$0",
                                  "TargetValue": "-0.000936034834012389"
                           },
                           "Outputs": [
                                  {
                                        "Ref": "scen2CleanShare",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "Number",
                                                            "Value": "0.00390082712173462",
                                                            "Format": "0.00%",
                                                            "Text": "0.39%"
                                                      }
                                               ]
                                        ]
                                  }
                           ],
                           "Success": true,
                           "InvalidToken": false,
                           "Messages": []
                    }
             },
             {
                    "Id": 2,
                    "Response": {
                           "Message": null,
                           "GoalSeek": {
                                  "Success": true,
                                  "ChangingFormat": "0.00%",
                                  "ChangingValue": "0.00589092922210693",
                                  "TargetFormat": "\"$\"#,##0",
                                  "TargetText": "$0",
                                  "TargetValue": "-2.53692269325256E-06"
                           },
                           "Outputs": [
                                  {
                                        "Ref": "scen2CleanShare",
                                        "Value": [
                                               [
                                                      {
                                                            "Type": "Number",
                                                            "Value": "0.00589092922210693",
                                                            "Format": "0.00%",
                                                            "Text": "0.59%"
                                                      }
                                               ]
                                        ]
                                  }
                           ],
                           "Success": true,
                           "InvalidToken": false,
                           "Messages": []
                    }
             }
       ],
       "Success": true,
      "InvalidToken": false,
       "Messages": []
}