Web API: Expression: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
'''Expression''' method runs the given expression and returns the result | '''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> | ||
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]]. | ||
== Example == | == Example == | ||
This example | This example uses an existing calculation session ''UserSession1'', and assumes that there is a variable ''variable1'' in that calculation session. | ||
<pre> | <pre> | ||
{ | { | ||
"contextType": " | "contextType": "Generic", | ||
"expression": " | "expression": "variable1 + 1", | ||
"sessionName": "UserSession1" | "sessionName": "UserSession1" | ||
} | } | ||
</pre> | </pre> |
Revision as of 09:47, 11 October 2021
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 /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:
- Expression (string): Expression to run.
- SessionName (string): Identifying name for the calculation session.
- ContextType (string): Same as in /api/expression/query.
- ModelId (integer): Same as in /api/expression/query.
- FilterId (integer): Same as in /api/expression/query.
- Filter (object): Same as in /api/expression/query.
- QueryIdentifier (string): Same as in /api/expression/query.
- CancelEarlierQueriesWithIdentifier (boolean): Same as in /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" }