Web API: Expression: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Expression''' method runs the given expression and returns the result of the calculated expression formatted as json. Each run is stored to a calculation session, and the same session can be continued in the next expression run. This way, for example initialized variables are available in the next run. Calculatation sessions are maintained in the server memory and dropper latest after 10 minutes if not used. The calculation session is related to the user session, so the calculations are not visible to other users or the same user if login to a new session. There can be multiple calculations sessions within the same user session.
'''Expression''' method runs the given expression and returns the result formatted as json. If the SessionName is provided, each run uses an existing calculation session, which can be continued in the next expression run, and for example initialized variables are available in the next run. Calculation sessions are maintained in the server memory and dropper latest after 10 minutes if not used. Calculation sessions are linked to the user session, so the calculations are not visible to other users or to the same user if using a new session. There can also be multiple calculations sessions within the same user session.


<pre>
<pre>
Url: POST /api/expression
Url: POST qprpa/api/expression
Content-Type: application/json;charset=UTF-8
Content-Type: application/json;charset=UTF-8
Body: (json object with parameters defined below)
Body: (json object with parameters defined below)
</pre>
</pre>


Following parameters can be used in the request body:
Following parameters can be used in the request body json object:
* '''Expression''' (string): Expression to run.
* '''Expression''' (string): Expression to run.
* '''SessionName''' (string): Identifying name for the calculation session.
* '''SessionName''' (string): Identifying name for the calculation session.
Line 13: Line 13:
* '''ModelId''' (integer): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''ModelId''' (integer): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''FilterId''' (integer): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''FilterId''' (integer): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''Filter''' (object): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''QueryIdentifier''' (string): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''QueryIdentifier''' (string): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''CancelEarlierQueriesWithIdentifier''' (boolean): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
* '''CancelEarlierQueriesWithIdentifier''' (boolean): Same as in [[Web_API:_Expression/query#Properties|/api/expression/query]].
Following parameter can be specified to the request url (query string):
* '''Timeout''' (integer): Timeout in seconds for the query. If the timeout is exceeded in a long-running query, the query execution is stopped and an error is returned. When no timeout is specified for the query, the server level global timeout is applied.
* '''EnableFullFunctionality''' (boolean): Same setting as in the [[Web_API:_Expression/query#Url_parameters|/api/expression/query]].


== Example ==
== Example ==
This example runs an expression in the Model context and show model id and name. It also assumes that there is a variable ''variable1'' available in the calculation session.
This example uses an existing calculation session ''UserSession1'', and assumes that there is a variable ''variable1'' in that calculation session.
<pre>
<pre>
{
{
   "contextType": "Model",
   "contextType": "Generic",
   "expression": "`${variable1}: ${Id}: ${Name}`",
   "expression": "variable1 + 1",
   "sessionName": "UserSession1",
   "sessionName": "UserSession1"
  "modelId": 123
}
}
</pre>
</pre>

Latest revision as of 20:33, 19 September 2022

Expression method runs the given expression and returns the result formatted as json. If the SessionName is provided, each run uses an existing calculation session, which can be continued in the next expression run, and for example initialized variables are available in the next run. Calculation sessions are maintained in the server memory and dropper latest after 10 minutes if not used. Calculation sessions are linked to the user session, so the calculations are not visible to other users or to the same user if using a new session. There can also be multiple calculations sessions within the same user session.

Url: POST qprpa/api/expression
Content-Type: application/json;charset=UTF-8
Body: (json object with parameters defined below)

Following parameters can be used in the request body json object:

Following parameter can be specified to the request url (query string):

  • Timeout (integer): Timeout in seconds for the query. If the timeout is exceeded in a long-running query, the query execution is stopped and an error is returned. When no timeout is specified for the query, the server level global timeout is applied.
  • EnableFullFunctionality (boolean): Same setting as in the /api/expression/query.

Example

This example uses an existing calculation session UserSession1, and assumes that there is a variable variable1 in that calculation session.

{
  "contextType": "Generic",
  "expression": "variable1 + 1",
  "sessionName": "UserSession1"
}