Evaluates a given decision and returns the result. The input values of the decision have to be supplied in the request body.

Method

POST /decision-definition/{id}/evaluate

POST /decision-definition/key/{key}/evaluate (evaluates the latest version of the decision definition which belongs to no tenant)

POST /decision-definition/key/{key}/tenant-id/{tenant-id}/evaluate (evaluates the latest version of the decision definition for tenant)

Parameters

Path Parameters

Name Description
id The id of the decision definition to be evaluated.
key The key of the decision definition (the latest version thereof) to be retrieved.
tenant-id The id of the tenant the decision definition belongs to.

Request Body

A JSON object with the following properties:

Name Description
Name Description
——-
variables A JSON object containing the variables the decision is to be evaluated with. Each key corresponds to a variable name and each value to a variable value. A variable value is a JSON object with the following properties:
NameDescription
valueThe variable's value. For variables of type Object, the serialized value has to be submitted as a String value.
For variables of type File the value has to be submitted as Base64 encoded string.
typeThe value type of the variable.
valueInfo A JSON object containing additional, value-type-dependent properties.
For serialized variables of type Object, the following properties can be provided:

- objectTypeName: A string representation of the object's type name.
- serializationDataFormat: The serialization format used to store the variable.
For serialized variables of type File, the following properties can be provided:

- filename: The name of the file. This is not the variable name but the name that will be used when downloading the file again.
- mimetype: The MIME type of the file that is being uploaded.
- encoding: The encoding of the file that is being uploaded.

|value|The variable's value. For variables of type Object, the serialized value has to be submitted as a String value.
For variables of type File the value has to be submitted as Base64 encoded string.
|type|The value type of the variable.|valueInfo| A JSON object containing additional, value-type-dependent properties.
For serialized variables of type Object, the following properties can be provided:

  • objectTypeName: A string representation of the object's type name.
  • serializationDataFormat: The serialization format used to store the variable.
    For serialized variables of type File, the following properties can be provided:

  • filename: The name of the file. This is not the variable name but the name that will be used when downloading the file again.

  • mimetype: The MIME type of the file that is being uploaded.
  • encoding: The encoding of the file that is being uploaded.
    |Name|Description
    |——-
    |value|The variable's value. For variables of type Object, the serialized value has to be submitted as a String value.
    For variables of type File the value has to be submitted as Base64 encoded string.

|type|The value type of the variable.
|valueInfo| A JSON object containing additional, value-type-dependent properties.
For serialized variables of type Object, the following properties can be provided:

  • objectTypeName: A string representation of the object's type name.
  • serializationDataFormat: The serialization format used to store the variable.
    For serialized variables of type File, the following properties can be provided:

  • filename: The name of the file. This is not the variable name but the name that will be used when downloading the file again.

  • mimetype: The MIME type of the file that is being uploaded.
  • encoding: The encoding of the file that is being uploaded.

Result

A JSON array representing the result of the newly evaluated decision. The array contains the output values as key-value pairs. Each key is an output name and each value an output value object that has the following properties:

Name Value Description
value String / Number / Boolean / Object The variable's value.
type String The value type of the variable.
valueInfo Object A JSON object containing additional, value-type-dependent properties.

For variables of type Object, the following properties are returned:

  • objectTypeName: A string representation of the object's type name.
  • serializationDataFormat: The serialization format used to store the variable.

See the user guide for details about the decision result.

Response codes

Code Media type Description
200 application/json Request successful.
403 application/json The authenticated user is unauthorized to evaluate this decision. See the Introduction for the error response format.
404 application/json The decision could not be evaluated due to a nonexistent decision definition. See the Introduction for the error response format.
500 application/json The decision could not be evaluated successfully. See the Introduction for the error response format.

Example

Request

POST /decision-definition/aDecisionDefinitionId/evaluate

POST /decision-definition/key/aDecisionDefinitionKey/evaluate

Request body:

  1. {
  2. "variables" : {
  3. "amount" : { "value" : 600, "type" : "Double" },
  4. "invoiceCategory" : { "value" : "Misc", "type" : "String" }
  5. }
  6. }

Response

  1. [
  2. {
  3. "result": { "value" : "management", "type" : "String", "valueInfo" : null }
  4. }
  5. ]

原文: https://docs.camunda.org/manual/7.9/reference/rest/decision-definition/post-evaluate/