Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 16. The REST API for Intelligent Process Server Execution
You can communicate with the Intelligent Process Server through the REST API.
-
The base URL for sending requests is the endpoint defined earlier, for example
http://SERVER:PORT/kie-server/services/rest/server/. -
All requests require basic HTTP Authentication or token-based authentication for the role
kie-server.
Following methods support three formats of the requests: JSON, JAXB, and XSTREAM. You must provide following HTTP headers:
Accept: set toapplication/jsonorapplication/xml.When specifying more than one accepted content type in the Accept header, be sure to include the qualifiers of preference (qvalues as defined in the HTML 1.1 standard). If you do not, unexpected behaviour may occur. This is an example of a well-formed header with multiple accepted content types:
Accept: application/xml; q=0.5, application/json; q=0.9
Accept: application/xml; q=0.5, application/json; q=0.9Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
X-KIE-ContentTypeis required when using the XSTREAM marshaller. In such case, set the header toXSTREAM. ValuesJSONandJAXBare allowed, but not required. When you set theContent-typetoapplication/xml, theJAXBvalue is used by default. -
Content-type: set toapplication/jsonorapplication/xml. This header corresponds with the format of your payload. --data: your payload. If the payload is in a file, start the name with an ampersand@. For example:--data @commandsRequest.json
--data @commandsRequest.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To ensure both the request and the response are in the same format, always specify both the Content-Type and Accept HTTP headers in your application’s requests. Otherwise, you can receive a marshalling-related error from the server.
The examples use the Curl utility. You can use any REST client. Curl commands use the following parameters:
-
-u: specifies username:password for the Intelligent Process Server authentication. -
-H: specifies HTTP headers. -
-X: specifies the HTTP method of the request, that is [GET], [POST], [PUT], or [DELETE].
BRMS Commands endpoints will work only if your Intelligent Process Server has BRM capability. The rest of the endpoints will work only if your Intelligent Process Server has BPM capabilities. Check the following URI for capabilities of your Intelligent Process Server : http://SERVER:PORT/kie-server/services/rest/server.
16.1. BRMS Commands Copier lienLien copié sur presse-papiers!
- [POST] /containers/instances/CONTAINER_ID
- Request Type
-
A single
org.kie.api.command.Commandcommand or multiples commands inBatchExecutionCommandwrapper. - Response Type
-
org.kie.server.api.model.ServiceResponse<String> - Description
-
Executes the commands sent to the specified
CONTAINER_IDand returns the commands execution results. For more information, See the supported commands below.
List of supported commands:
-
AgendaGroupSetFocusCommand -
ClearActivationGroupCommand -
ClearAgendaCommand -
ClearAgendaGroupCommand -
ClearRuleFlowGroupCommand -
DeleteCommand -
InsertObjectCommand -
ModifyCommand -
GetObjectCommand -
InsertElementsCommand -
FireAllRulesCommand -
QueryCommand -
SetGlobalCommand -
GetGlobalCommand -
GetObjectsCommand -
BatchExecutionCommand -
DisposeCommand
For more information about the commands, see the org.drools.core.command.runtime package. Alternatively, see Supported Red Hat JBoss BRMS Commands from the Red Hat JBoss Development Guide.
Example 16.1. [POST] Drools Commands Execution
Change into a directory of your choice and create
commandsRequest.json:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command:
curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @commandsRequest.json http://localhost:8080/kie-server/services/rest/server/containers/instances/myContainer
$ curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @commandsRequest.json http://localhost:8080/kie-server/services/rest/server/containers/instances/myContainerCopy to Clipboard Copied! Toggle word wrap Toggle overflow The command generates a request that sends the
InsertObjectandFireAllRulescommands to the server. Thelookupattribute sets the KIE session ID on which the commands will be executed. For stateless KIE sessions, this attribute is required. For stateful KIE sessions, this attribute is optional and if not specified, the default KIE session is used.
An example response:
{
"type" : "SUCCESS",
"msg" : "Container hello successfully called.",
"result" : "{\n \"results\" : [ ],\n \"facts\" : [ ]\n}"
}
{
"type" : "SUCCESS",
"msg" : "Container hello successfully called.",
"result" : "{\n \"results\" : [ ],\n \"facts\" : [ ]\n}"
}
16.2. Managing Processes Copier lienLien copié sur presse-papiers!
Use the following entry point: http://SERVER:PORT/kie-server/services/rest/server/containers/CONTAINER_ID/processes. See the list of endpoints:
- [DELETE] /instances
- Description
-
Aborts multiple process instances specified by the query parameter
instanceId.
- [GET] /instances/PROCESS_INSTANCE_ID/signals
- Response Type
- A list of Strings.
- Description
-
Returns all the available signal names for
PROCESS_INSTANCE_IDas a list of Strings.
- [PUT] /instances/PROCESS_INSTANCE_ID/variable/VARIABLE_NAME
- Request Type
- The variable marshalled value.
- Description
-
Sets the value of the
VARIABLE_NAMEvariable for thePROCESS_INSTANCE_IDprocess instance. If successful, the return value is HTTP code 201.
- [GET] /instances/PROCESS_INSTANCE_ID/variable/VARIABLE_NAME
- Response Type
- The variable value.
- Description
-
Returns the marshalled value of the
VARIABLE_NAMEvariable for thePROCESS_INSTANCE_IDprocess instance.
- [POST] /instances/PROCESS_INSTANCE_ID/variables
- Request Type
- A map with variable names and values.
- Description
-
Sets multiple variables that belong to a
PROCESS_INSTANCE_IDprocess instance. The request is a map, in which the key is the name of the variable and the value is the new value of the variable.
- [GET] /instances/PROCESS_INSTANCE_ID/variables
- Response Type
- A map with the variable names and values.
- Description
-
Gets all variables for the
PROCESS_INSTANCE_IDprocess instance as a map, in which the key is the name of the variable and the value is the value of the variable.
- [GET] /instances/PROCESS_INSTANCE_ID/workitems
- Response Type
- A list of WorkItemInstance objects.
- Description
-
Gets all the work items of the given
PROCESS_INSTANCE_IDprocess instance.
- [GET] /instances/PROCESS_INSTANCE_ID/workitems/WORK_ITEM_ID
- Response Type
- A WorkItemInstance object.
- Description
-
Gets the
WORK_ITEM_IDwork item of the givenPROCESS_INSTANCE_IDprocess instance.
- [PUT] /instances/PROCESS_INSTANCE_ID/workitems/WORK_ITEM_ID/aborted
- Description
-
Aborts the
WORK_ITEM_IDwork item of the givenPROCESS_INSTANCE_IDprocess instance. If successful, the return value is HTTP code 201.
- [PUT] /instances/PROCESS_INSTANCE_ID/workitems/WORK_ITEM_ID/completed
- Description
-
Completes the
WORK_ITEM_IDwork item of the givenPROCESS_INSTANCE_IDprocess instance. If successful, the return value is HTTP code 201.
- [POST] /PROCESS_ID/instances
- Request Type
- A map with variables used to start the process.
- Response Type
- Plain text with the process instance id.
- Description
-
Creates a
PROCESS_IDbusiness process instance. Accepted input is a map with the process variables and its values.
- [POST] /instances/signal/SIGNAL_NAME
- Request Type
- A marshalled object.
- Description
-
Signals multiple process instances of a query parameter
instanceIdwith theSIGNAL_NAMEsignal. You can provide the signal payload marshalled in the request body.
- [DELETE] /instances/PROCESS_INSTANCE_ID
- Description
-
Aborts the
PROCESS_INSTANCE_IDprocess instance. If successful, the return value is HTTP code 204.
- [GET] /instances/PROCESS_INSTANCE_ID
- Response Type
- A Process Instance object.
- Description
-
Returns the details of the
PROCESS_INSTANCE_IDprocess instance. You can request variable information by setting thewithVarsparameter as true.
- [POST] /instances/PROCESS_INSTANCE_ID/signal/SIGNAL_NAME
- Request Type
- A marshalled object.
- Description
-
Signals the
PROCESS_INSTANCE_IDprocess instance withSIGNAL_NAMEsignal. You can provide the signal payload marshalled in the request body.
- [POST] /PROCESS_ID/instances/correlation/CORRELATION_KEY
- Request Type
- A map with variables used to start the process.
- Response Type
- Plain text with the process instance id.
- Description
-
Creates the
PROCESS_IDbusiness process instance with theCORRELATION_KEYcorrelation key. Accepted input is a map with the process variables and its values.
Example 16.2. Managing Processes
Create
person.json:{ "p" : { "org.kieserver.test.Person": { "id" : 13, "name": "William" } } }{ "p" : { "org.kieserver.test.Person": { "id" : 13, "name": "William" } } }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start a process using a custom object (Person) as a parameter:
curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data @person.json 'http://localhost:8080/kie-server/services/rest/server/containers/person/processes/proc-with-pojo.p-proc/instances'
$ curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data @person.json 'http://localhost:8080/kie-server/services/rest/server/containers/person/processes/proc-with-pojo.p-proc/instances'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new process instance of process definition
com.sample.rewards-basicwith parameters:curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '{"employeeName": "William"}' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/com.sample.rewards-basic/instances'$ curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '{"employeeName": "William"}' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/com.sample.rewards-basic/instances'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Returns process instance ID.
Get the variables of process instance
3curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/instances/3/variables'
$ curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/instances/3/variables'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example response:
{ "employeeName" : "William" }{ "employeeName" : "William" }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Send a TEST signal to the process instance with ID
5curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '"SIGNAL DATA"' 'http://localhost:8080/kie-server/services/rest/server/containers/test/processes/instances/signal/TEST?instanceId=5'
$ curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '"SIGNAL DATA"' 'http://localhost:8080/kie-server/services/rest/server/containers/test/processes/instances/signal/TEST?instanceId=5'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.3. Managing Process Definitions Copier lienLien copié sur presse-papiers!
Use the following entry point: http://SERVER:PORT/kie-server/services/rest/server/containers/CONTAINER_ID/processes/definitions. See table Process Queries Endpoints for a list of endpoints. To use pagination, use the page and pageSize parameters.
- [GET] /PROCESS_ID/variables
- Response Type
- A VariablesDefinition object.
- Description
-
Returns a map of the variable definitions for the
PROCESS_IDprocess. The map contains the variable name and its type.
- [GET] /PROCESS_ID/tasks/service
- Response Type
- A ServiceTaskDefinition object.
- Description
-
Returns all service tasks for the
PROCESS_IDprocess. The return value is a map with the names and types of the service tasks. If no tasks are found, the return value is an empty list.
- [GET] /PROCESS_ID/tasks/users
- Response Type
- A list of UserTaskDefinition objects.
- Description
-
Returns all the user tasks for the
PROCESS_IDprocess. The response also contains maps of the input and output parameters. The key is the name and the value is the type of a parameter.
- [GET] /PROCESS_ID/subprocesses
- Response Type
- A SubProcessDefinition object.
- Description
-
Returns a list of reusable sub-process IDs for the
PROCESS_IDprocess.
- [GET] /PROCESS_ID/entities
- Response Type
- An AssociatedEntitiesDefinition object.
- Description
-
Returns a map with the entities associated with the
PROCESS_IDprocess.
- [GET] /PROCESS_ID/tasks/users/TASK_NAME/inputs
- Response Type
- A TaskInputsDefinition object.
- Description
- Returns a map with all the task input parameter definitions for the TASK_NAME task of the PROCESS_ID process. The key is the name of the input and the value is its type.
- [GET] /PROCESS_ID/tasks/users/TASK_NAME/outputs
- Response Type
- A TaskOutputsDefinition object.
- Description
- Returns a map with all the task output parameter definitions for the TASK_NAME task of the PROCESS_ID process. The key is the name of the input and the value is its type.
Example 16.3. [GET] User Tasks for a Specified Process
The following command displays user tasks for the the com.sample.rewards-basic process in the rewards container:
curl -u 'kieserver:kieserver1!' -H 'accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/definitions/com.sample.rewards-basic/tasks/users'
$ curl -u 'kieserver:kieserver1!' -H 'accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/definitions/com.sample.rewards-basic/tasks/users'
An example response:
Example 16.4. [GET] Variable Definitions for Specified Process
The following command displays the variable definitions of the com.sample.rewards-basic process in the rewards container:
curl -u 'kieserver:kieserver1!' -H 'accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/definitions/com.sample.rewards-basic/variables'
$ curl -u 'kieserver:kieserver1!' -H 'accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/definitions/com.sample.rewards-basic/variables'
An example response:
16.4. Managing User Tasks Copier lienLien copié sur presse-papiers!
16.4.1. Managing Task Instances Copier lienLien copié sur presse-papiers!
Use this base URI: http://SERVER:PORT/kie-server/services/rest/server/containers/CONTAINER_ID/tasks/TASK_ID/states. If successful, the return value is HTTP code 201. See the list of endpoints:
- [PUT] /activated
- Description
-
Activates the
TASK_IDtask.
- [PUT] /claimed
- Description
-
Claims the
TASK_IDtask.
- [PUT] /started
- Description
-
Starts the
TASK_IDtask.
- [PUT] /stopped
- Description
-
Stops the
TASK_IDtask.
- [PUT] /completed
- Request Type
- A map with the output parameters name and value.
- Description
-
Completes the
TASK_IDtask. You can provide the output parameters as a map, where the key is the parameter name and the value is the value of the output parameter. You can also use theauto-progressparameter. If set to true, it will claim, start, and complete a task at once.
- [PUT] /delegated
- Description
-
Delegates the
TASK_IDtask to a user provided by thetargetUserquery parameter.
- [PUT] /exited
- Description
-
Exits the
TASK_IDtask.
- [PUT] /failed
- Description
-
Fails the
TASK_IDtask.
- [PUT] /forwarded
- Description
-
Forwards the
TASK_IDtask to the user provided by thetargetUserquery parameter.
- [PUT] /released
- Description
-
Releases the
TASK_IDtask.
- [PUT] /resumed
- Description
-
Resumes the
TASK_IDtask.
- [PUT] /skipped
- Description
-
Skips the
TASK_IDtask.
- [PUT] /suspended
- Description
-
Suspends the
TASK_IDtask.
- [PUT] /nominated
- Description
-
Nominates the
TASK_IDtask to the potential owners by thepotOwnerquery parameter. You can use the parameter multiple times, for example:potOwner=usr1&potOwner=usr2.
Example 16.5. Task Instances
Start task with
taskId4 in the containertest:curl -X PUT -u 'kieserver:kieserver1!' http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/4/states/started
$ curl -X PUT -u 'kieserver:kieserver1!' http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/4/states/startedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Complete the task 1 by passing an output parameter:
curl -X PUT -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '{ "_approval" : true }' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/1/states/completed'$ curl -X PUT -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '{ "_approval" : true }' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/1/states/completed'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Some operations are illegal, such as starting a completed task, or disallowed for security reasons, such as claiming a task for another user. Having different sets of users for authentication and task management can be a security concern. Making such requests will result in one of the following exceptions:
Unexpected error during processing User '[UserImpl:'{USER ID}']' does not have permissions to execute operation OPERATION on task id {$TASK_ID}
Unexpected error during processing User '[UserImpl:'{USER ID}']' does not have permissions to execute operation OPERATION on task id {$TASK_ID}
Unexpected error during processing: User '[UserImpl:'{USER ID}']' was unable to execute operation OPERATION on task id {$TASK_ID} due to a no 'current status' match
Unexpected error during processing: User '[UserImpl:'{USER ID}']' was unable to execute operation OPERATION on task id {$TASK_ID} due to a no 'current status' match
Ensure the operation you are executing is allowed for the current task status. You can disable the security settings by using the org.kie.server.bypass.auth.user property.
For example, on Red Hat JBoss EAP, open EAP_HOME/standalone/configuration/standalone.xml and enter the following:
<system-properties> ... <property name="org.kie.server.bypass.auth.user" value="true"/> ... </system-properties>
<system-properties>
...
<property name="org.kie.server.bypass.auth.user" value="true"/>
...
</system-properties>
Alternatively, use -Dorg.kie.server.bypass.auth.user=true to set the property. If you use the Intelligent Process Server Java client API, set the property on your client as well:
System.setProperty("org.kie.server.bypass.auth.user", "true");
System.setProperty("org.kie.server.bypass.auth.user", "true");
When you turn on the security settings, you can provide a user with sufficient permissions to execute the operation using the query parameter ?user=$USER_NAME. If you do not use the parameter, the authenticated user will be used to perform the action.
If you disabled the security settings and still experience authentication issues, configure the Intelligent Process Server callback:
Configuring UserGroupCallback
Override the default JAAS UserGroupCallback on the server side:
<property name="org.jbpm.ht.callback" value="props"/> <!-- If necessary, override the userinfo configuration as well. --> <property name="org.jbpm.ht.userinfo" value="props"/>
<property name="org.jbpm.ht.callback" value="props"/> <!-- If necessary, override the userinfo configuration as well. --> <property name="org.jbpm.ht.userinfo" value="props"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow See the source code for other possible values.
For the
propsvalue, specify the location of theapplication-roles.propertiesfile:<property name="jbpm.user.group.mapping" value="file:///EAP_HOME/standalone/configuration/application-roles.properties"/> <!-- If no other file is specified, the business-central.war/WEB-INF/classes/userinfo.properties file is used. You can specify a file with the following property: <property name="jbpm.user.info.properties" value="file:///path" /> -->
<property name="jbpm.user.group.mapping" value="file:///EAP_HOME/standalone/configuration/application-roles.properties"/> <!-- If no other file is specified, the business-central.war/WEB-INF/classes/userinfo.properties file is used. You can specify a file with the following property: <property name="jbpm.user.info.properties" value="file:///path" /> -->Copy to Clipboard Copied! Toggle word wrap Toggle overflow
You can also use a different callback object. The Human Task callback is instantiated by a CDI producer configured in EAP_HOME/standalone/business-central.war/WEB-INF/beans.xml:
Red Hat JBoss BPM Suite provides out-of-the-box producer and callback objects you can use. See the source code for a list of additional setting required for each callback implementation:
DBUserGroupCallback:
LDAPUserGroupCallback:
MvelUserGroupCallbackImpl:
16.4.2. Managing Task Instance Data Copier lienLien copié sur presse-papiers!
Use this base URI: http://SERVER:PORT/kie-server/services/rest/server/containers/CONTAINER_ID/tasks/TASK_ID. See table Task Instance Data Management Endpoints for a list of endpoints.
- [GET] /
- Response Type
- A TaskInstance object.
- Description
-
Gets the
TASK_IDtask instance details.
- [POST] /attachments
- Request Type
- The content of the attachment.
- Response Type, Description
-
Adds a new attachment for the
TASK_IDtask. The ID of the created content is returned in the response, which is HTTP code 201. The name of the attachment is set using the query parametername. If you make multiples request, you create multiple attachments.
- [GET] /attachments
- Response Type
- A list of TaskAttachment objects.
- Description
-
Gets all task attachments for the
TASK_IDtask.
- [GET] /attachments/ATTACHMENT_ID
- Response Type
- A TaskAttachment object.
- Description
-
Gets the
ATTACHMENT_IDtask attachment.
- [DELETE] /attachments/ATTACHMENT_ID
- Description
-
Removes the
ATTACHMENT_IDtask attachment.
- [GET] /attachments/ATTACHMENT_ID/content
- Response Type
- An attachment-type object.
- Description
-
Gets the
ATTACHMENT_IDtask attachment content.
- [POST] /comments
- Request Type
- A TaskComment object.
- Response Type
- Long.
- Description
-
Adds a new comment for the
TASK_IDtask. The ID of the created content is returned in the response, which HTTP code is 201. If you make multiples request, you create multiple comments.
- [GET] /comments
- Response Type
- A list of TaskComment objects.
- Description
-
Gets all task comments for the
TASK_IDtask.
- [GET] /comments/COMMENT_ID
- Response Type
- A TaskComment object.
- Description
-
Gets the
COMMENT_IDtask comment of theTASK_IDtask.
- [DELETE] /comments/COMMENT_ID
- Description
-
Deletes the
COMMENT_IDtask comment of theTASK_IDtask.
- [GET] /contents/input
- Response Type
- A map with the input parameters name and value.
- Description
-
Gets the
TASK_IDtask input content in form of a map, where the key is the parameter name and the value is the value of the output parameter.
- [PUT] /contents/output
- Request Type
- A map with the output parameters name and value.
- Description
-
Updates the
TASK_IDtask output parameters and returns HTTP 201 if successful. Provide the output parameters as a map, where the key is the parameter name and the value is the value of the output parameter.
- [GET] /contents/output
- Response Type
- A map with the output parameters name and value.
- Description
-
Gets the
TASK_IDtask output content in form of a map, where the key is the parameter name and the value is the value of the output parameter.
- [DELETE] /contents/CONTENT_ID
- Description
-
Deletes the
CONTENT_IDcontent and returns HTTP code 204.
- [PUT] /description
- Request Type
- Marshalled String value.
- Description
-
Updates the
TASK_IDtask description and returns HTTP code 201 if successful. Provide the new value for description in the request body.
- [PUT] /expiration
- Request Type
- Marshalled Date value.
- Description
-
Updates the
TASK_IDtask expiration date and returns HTTP 201 if successful. Provide the new value for the expiration date in the request body.
- [PUT] /name
- Request Type
- Marshalled String value.
- Description
-
Updates the
TASK_IDtask name and returns HTTP code 201 if successful. Provide the new value for name in the request body.
- [PUT] /priority
- Request Type
- Marshalled int value.
- Description
-
Updates the
TASK_IDtask priority and returns HTTP code 201 if successful. Provide the new value for priority in the request body.
- [PUT] /skipable
- Request Type
- Marshalled Boolean value.
- Description
-
Updates the
TASK_IDtask propertyskipableand returns HTTP code 201 if successful. Provide the new value for priority in the request body.
Example 16.6. User Task Instance Data
Get a user task instance for container
test:curl -X GET -u 'kieserver:kieserver1!' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/1'
$ curl -X GET -u 'kieserver:kieserver1!' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/1'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example response:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set priority to 3 for task 1:
curl -X PUT -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '3' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/1/priority'
$ curl -X PUT -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '3' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/1/priority'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a comment to a task 2:
curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '{ "comment" : "One last comment", "comment-added-by": "kieserver"}' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/2/comments'$ curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' -H 'X-KIE-ContentType: JSON' --data '{ "comment" : "One last comment", "comment-added-by": "kieserver"}' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/2/comments'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get all task comments:
curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/2/comments'
$ curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/2/comments'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example response:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.5. Querying Process Instances Copier lienLien copié sur presse-papiers!
Use the following entry point: http://SERVER:PORT/kie-server/services/rest/server/queries/. To use pagination, use the page and pageSize parameters.
- [GET] processes/instances
Returns a list of process instances.
Additional parameters you can use:
status,initiator,processName.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/PROCESS_ID/instances
Returns a list of process instances for the specified process.
Additional parameters you can use:
status,initiator.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] containers/CONTAINER_ID/process/instances
Returns a list of process instances for the specified container.
Additional parameters you can use:
status.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/instance/correlation/CORRELATION_KEY
- Returns an instance with the specified correlation key.
- [GET] processes/instances/correlation/CORRELATION_KEY
- Returns a list of instances with the specified correlation key.
- [GET] processes/instances/PROCESS_INSTANCE_ID
Returns information about the specified process instance.
Additional parameters you can use:
withVars.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/instances/variables/VARIABLE_NAME
Returns process instance with the specified variable.
Additional parameters you can use:
status,varValue.Note that you can use wildcard characters with
varValue, for examplevarValue=waiting%to list all the values that start withwaiting.Example Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] containers/CONTAINER_ID/processes/definitions
Returns a list of process definitions available for the container.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/definitions
Returns list of process definitions.
Additional parameters you can use:
filter.Note that the
filterparameter filters all the process definitions that contain the given substring.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] containers/CONTAINER_ID/processes/definitions/PROCESS_ID
Returns process definition of the specified process instance in the specified container.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/definitions/PROCESS_ID
Returns a list of process definitions of the specified process.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/instances/PROCESS_INSTANCE_ID/nodes/instances
Returns node instances for the specified process instance.
Additional parameters you can use:
activeOnly,completedOnly.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/instances/PROCESS_INSTANCE_ID/wi-nodes/instances/WORK_ITEM_ID
- Returns node instances for the specified work item in the specified process instance.
- [GET] processes/instances/PROCESS_INSTANCE_ID/variables/instances
Returns current variable values of the specified process instance.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] processes/instances/PROCESS_INSTANCE_ID/variables/instances/VARIABLE_NAME
Returns the value of the given variable in the specified process instance.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.6. Querying Tasks Copier lienLien copié sur presse-papiers!
Use the following entry point: http://SERVER:PORT/kie-server/services/rest/server/queries/. To use pagination, use the page and pageSize parameters. The following list of endpoints contains additional parameters, if applicable:
- [GET] tasks/instances/pot-owners
Returns a list of tasks where the actual user is defined as a potential owner.
Additional parameters you can use:
status,groups,user.Note that the
userfilter is applicable only when the request is sent without authentication.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] tasks/instances/admins
Returns a list of tasks assigned to the Business Administrator.
Additional parameters you can use:
status,user.- [GET] tasks/instances/owners
Returns a list of tasks that the querying user owns.
Additional parameters you can use:
status,user.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] tasks/instances
Returns a list of instances available for the querying user.
Additional parameters you can use:
user.- [GET] tasks/instances/TASK_INSTANCE_ID/events
Returns a list of events for the specified task instance.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] tasks/instances/TASK_INSTANCE_ID
Returns information about the specified task instance.
Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] tasks/instances/workitem/WORK_ITEM_ID
- Returns a list of task instances that use the specified work item.
- [GET] tasks/instances/process/PROCESS_INSTANCE_ID
Returns a list of tasks attached to the specified process instance.
Additional parameters you can use:
status.Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] tasks/instances/variables/VARIABLE_NAME
Returns a list of tasks that use the specified variable.
Aditional parameters you can use:
varValue,status,user.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.7. Advanced Queries for the Intelligent Process Server Copier lienLien copié sur presse-papiers!
The Intelligent Process Server supports the following commands through the REST API. For more information about advanced queries for the Intelligent Process Server, see Section 12.9, “Advanced Queries with QueryService”. For more information about using advanced queries in the Java Client API, see Section 19.10, “QueryDefinition for Intelligent Process Server Using Java Client API”.
Use the following entry point: http://SERVER:PORT/kie-server/services/rest/server/queries/definitions.
For endpoints that include MAPPER_ID, you can use following default mappers:
org.jbpm.kie.services.impl.query.mapper.ProcessInstanceQueryMapper-
registered with name -
ProcessInstances
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.ProcessInstanceWithVarsQueryMapper-
registered with name -
ProcessInstancesWithVariables
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.ProcessInstanceWithCustomVarsQueryMapper-
registered with name -
ProcessInstancesWithCustomVariables
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.UserTaskInstanceQueryMapper-
registered with name -
UserTasks
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.UserTaskInstanceWithVarsQueryMapper-
registered with name -
UserTasksWithVariables
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.UserTaskInstanceWithCustomVarsQueryMapper-
registered with name -
UserTasksWithCustomVariables
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.TaskSummaryQueryMapper-
registered with name -
TaskSummaries
-
registered with name -
org.jbpm.kie.services.impl.query.mapper.RawListQueryMapper-
registered with name -
RawList
-
registered with name -
Advanced Queries Endpoints
- [GET] /
- Returns query definitions.
- [GET] /QUERY_NAME
- Returns information about the specified query.
- [POST] /QUERY_NAME
- Registers a query definition.
Request Body
- [PUT] /QUERY_NAME
- This endpoint updates a query definition.
Request Body
- [DELETE] /QUERY_NAME
- This endpoint deletes a query.
- [GET] /QUERY_NAME/data?mapper=MAPPER_ID
- This endpoint queries tasks with no filtering. You can use either default or custom mappers.
- [POST] /QUERY_NAME/filtered-data?mapper=MAPPER_ID
This endpoint queries tasks with filters specified in the request body.
Request Body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /QUERY_NAME/filtered-data?mapper=MAPPER_ID&builder=BUILDER_ID
This endpoint queries tasks with QueryParamBuilder. Pass the QueryParamBuilder variables in the request body.
Request Body
{ "min" : 10, "max" : 20 }{ "min" : 10, "max" : 20 }Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To use advanced queries through the REST API:
Change into a directory of your choice and create an XML file with your query definition. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Send a POST request to register your query definition. For example:
curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/xml' --data @queryDefinition.xml 'http://localhost:8080/kie-server/services/rest/server/queries/definitions/getAllTasks'
$ curl -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/xml' --data @queryDefinition.xml 'http://localhost:8080/kie-server/services/rest/server/queries/definitions/getAllTasks'Copy to Clipboard Copied! Toggle word wrap Toggle overflow To get the results of the query execution, send a GET request to queries/definitions/getAllTasks/data. For example:
curl -u 'kieserver:kieserver1!' -H 'Accept: application/xml' 'http://localhost:8080/kie-server/services/rest/server/queries/definitions/getAllTasks/data?mapper=UserTasks&orderBy=&page=0&pageSize=100'
curl -u 'kieserver:kieserver1!' -H 'Accept: application/xml' 'http://localhost:8080/kie-server/services/rest/server/queries/definitions/getAllTasks/data?mapper=UserTasks&orderBy=&page=0&pageSize=100'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Server Response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.8. Managing Job Execution Copier lienLien copié sur presse-papiers!
REST API allows you to access information about asynchronous jobs without using the Business Central directly. The Intelligent Process Server exposes a component for executing asynchronous tasks through REST and JMS. The exposed API then offers you an access to:
- Schedule a new job.
- Cancel an already scheduled job.
-
Add a failed job to the queue again by giving the relevant
JOB_ID. -
Get a particular job by its
JOB_ID. - Query jobs scheduled to execute the same command (given as a parameter).
-
Query jobs scheduled with the same given
BUSINESS_KEY. - Query jobs with the given status as a parameter.
To control job execution, use the URI http://SERVER_ADDRESS:PORT/kie-server/services/rest/server/jobs.
For example http://localhost:8080/kie-server/services/rest/server/jobs.
Job Execution Endpoints
See the list of available endpoints:
- [GET] /
Response type: list of
RequestInfoInstanceobjectsDescription: Use this endpoint to query jobs in the server. Moreover, you can specify the parameters
page,pageSize, andstatus; possible values for status are QUEUED, DONE, CANCELLED, ERROR, RETRYING, and RUNNING. Note that these values must be capitalized.- [POST] /
Request type:
RequestInfoInstanceobjectResponse type: created
JOB_IDDescription: Creates a new job request and returns its ID. It is possible to assign the job to a container by setting
CONTAINER_ID.- [GET] /commands/JOB_COMMAND_NAME
Response type: list of
RequestInfoInstanceobjectsDescription: Returns a list of jobs configured to run with the
JOB_COMMAND_NAMEcommand class.- [GET] /JOB_ID
Response type:
RequestInfoInstanceobjectDescription: Returns details of a job request with the provided
JOB_ID. You can specify the parameterswithErrors(boolean) to include errors of an execution andwithDatato include the data associated with the job.- [DELETE] /JOB_ID
-
Description: Cancels a job with the given
JOB_ID. If successful, returns HTTP code 204, otherwise HTTP code 500. - [PUT] /JOB_ID
Request type:
RequestInfoInstanceobjectDescription: Requests unfinished or failed job request with the given
JOB_IDand reassigns it into the job queue.- [GET] /keys/BUSINESS_KEY
Response type: list of
RequestInfoInstanceobjectsDescription: Returns a list of jobs that match the given
BUSINESS_KEY.
Example 16.7. [POST] New Job
Change into a directory of your choice and create a
jobRequest.xmlfile with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command:
curl -X POST --data @jobRequest.xml -u 'kieserver:kieserver1!' -H 'content-type: application/xml' 'http://localhost:8080/kie-server/services/rest/server/jobs/'
$ curl -X POST --data @jobRequest.xml -u 'kieserver:kieserver1!' -H 'content-type: application/xml' 'http://localhost:8080/kie-server/services/rest/server/jobs/'Copy to Clipboard Copied! Toggle word wrap Toggle overflow An example response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <long-type> <value>4</value> </long-type>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <long-type> <value>4</value> </long-type>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 16.8. [GET] List All Jobs
To list all jobs in the JSON format, execute the following command:
curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/jobs?status=QUEUED&status=DONE&status=CANCELLED&status=ERROR&status=RETRYING&status=RUNNING'
$ curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/jobs?status=QUEUED&status=DONE&status=CANCELLED&status=ERROR&status=RETRYING&status=RUNNING'
An example response: