The OpCon API provides a powerful endpoint for evaluating expressions, which is especially useful for testing property expressions, date formats, and conditional logic used in Self Service, job dependencies, and other automation scenarios.
Why Use the Expression Evaluation Endpoint?
This endpoint allows you to:
- Validate expression syntax before using it in production.
- Preview the evaluated result of date and property expressions.
- Test conditional logic used in disable/hide rules or job dependencies.
Endpoint Overview
The endpoint used for evaluating expressions is:
POST /expressions/evaluate
Example 1: Evaluating a Date Expression
To evaluate a date expression like `$DATE`, send the following JSON payload:
{
"expression": "$DATE"
}
A successful response might look like:
{
"expression": "$DATE",
"status": "Success",
"result": "2024-04-17"
}
Example 2: Evaluating a Conditional Expression
You can also evaluate logical expressions. For example:
{
"expression": "$DAYOFWEEK == 'Monday'"
}
This will return a Boolean result indicating whether the current day is Monday.
Example 3: Testing Expression Syntax
If your expression contains a syntax error, the API will return a failure status. For example:
{
"expression": "$DATE +"
}
Might return:
{
"expression": "$DATE +",
"status": "Failure",
"result": "Syntax error: unexpected end of expression"
}
Use Cases
- Test expressions used in Self Service forms (e.g., disable/hide rules).
- Validate job completion expressions.
- Preview date formatting and logic before applying to schedules or properties.
Tips
- Always prefix property names with ‘$’.
- Use the Swagger interface to test expressions interactively.
- Check the `status` field in the response to confirm success or failure.
- Ensure your token is correctly formatted with the prefix ‘Token.’