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/json
orapplication/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
-
X-KIE-ContentType
is required when using the XSTREAM marshaller. In such case, set the header toXSTREAM
. ValuesJSON
andJAXB
are allowed, but not required. When you set theContent-type
toapplication/xml
, theJAXB
value is used by default. -
Content-type
: set toapplication/json
orapplication/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
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
- [POST] /containers/instances/CONTAINER_ID
- Request Type
-
A single
org.kie.api.command.Command
command or multiples commands inBatchExecutionCommand
wrapper. - Response Type
-
org.kie.server.api.model.ServiceResponse<String>
- Description
-
Executes the commands sent to the specified
CONTAINER_ID
and 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
:{ "lookup" : "ksession1", "commands" : [ { "insert" : { "object" : "testing", "disconnected" : false, "out-identifier" : null, "return-object" : true, "entry-point" : "DEFAULT" } }, { "fire-all-rules" : { } } ] }
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
The command generates a request that sends the
InsertObject
andFireAllRules
commands to the server. Thelookup
attribute 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}" }
16.2. Managing Processes
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_ID
as 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_NAME
variable for thePROCESS_INSTANCE_ID
process 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_NAME
variable for thePROCESS_INSTANCE_ID
process 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_ID
process 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_ID
process 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_ID
process instance.
- [GET] /instances/PROCESS_INSTANCE_ID/workitems/WORK_ITEM_ID
- Response Type
- A WorkItemInstance object.
- Description
-
Gets the
WORK_ITEM_ID
work item of the givenPROCESS_INSTANCE_ID
process instance.
- [PUT] /instances/PROCESS_INSTANCE_ID/workitems/WORK_ITEM_ID/aborted
- Description
-
Aborts the
WORK_ITEM_ID
work item of the givenPROCESS_INSTANCE_ID
process 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_ID
work item of the givenPROCESS_INSTANCE_ID
process 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_ID
business 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
instanceId
with theSIGNAL_NAME
signal. You can provide the signal payload marshalled in the request body.
- [DELETE] /instances/PROCESS_INSTANCE_ID
- Description
-
Aborts the
PROCESS_INSTANCE_ID
process 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_ID
process instance. You can request variable information by setting thewithVars
parameter as true.
- [POST] /instances/PROCESS_INSTANCE_ID/signal/SIGNAL_NAME
- Request Type
- A marshalled object.
- Description
-
Signals the
PROCESS_INSTANCE_ID
process instance withSIGNAL_NAME
signal. 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_ID
business process instance with theCORRELATION_KEY
correlation 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" } } }
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'
Create a new process instance of process definition
com.sample.rewards-basic
with 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'
Returns process instance ID.
Get the variables of process instance
3
$ curl -u 'kieserver:kieserver1!' -H 'Accept: application/json' 'http://localhost:8080/kie-server/services/rest/server/containers/rewards/processes/instances/3/variables'
Example response:
{ "employeeName" : "William" }
Send a TEST signal to the process instance with ID
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'
16.3. Managing Process Definitions
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_ID
process. 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_ID
process. 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_ID
process. 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_ID
process.
- [GET] /PROCESS_ID/entities
- Response Type
- An AssociatedEntitiesDefinition object.
- Description
-
Returns a map with the entities associated with the
PROCESS_ID
process.
- [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'
An example response:
{ "task" : [ { "task-name" : "Approval by PM", "task-priority" : 0, "task-skippable" : false, "associated-entities" : [ "PM" ], "task-inputs" : { "Skippable" : "Object", "TaskName" : "java.lang.String", "GroupId" : "Object" }, "task-outputs" : { "_approval" : "Boolean" } }, { "task-name" : "Approval by HR", "task-priority" : 0, "task-skippable" : false, "associated-entities" : [ "HR" ], "task-inputs" : { "Skippable" : "Object", "TaskName" : "java.lang.String", "GroupId" : "Object" }, "task-outputs" : { "_approval" : "Boolean" } } ] }
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'
An example response:
{ "variables" : { "result" : "String", "hrApproval" : "Boolean", "pmApproval" : "Boolean", "employeeName" : "String" } }
16.4. Managing User Tasks
16.4.1. Managing Task Instances
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_ID
task.
- [PUT] /claimed
- Description
-
Claims the
TASK_ID
task.
- [PUT] /started
- Description
-
Starts the
TASK_ID
task.
- [PUT] /stopped
- Description
-
Stops the
TASK_ID
task.
- [PUT] /completed
- Request Type
- A map with the output parameters name and value.
- Description
-
Completes the
TASK_ID
task. 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-progress
parameter. If set to true, it will claim, start, and complete a task at once.
- [PUT] /delegated
- Description
-
Delegates the
TASK_ID
task to a user provided by thetargetUser
query parameter.
- [PUT] /exited
- Description
-
Exits the
TASK_ID
task.
- [PUT] /failed
- Description
-
Fails the
TASK_ID
task.
- [PUT] /forwarded
- Description
-
Forwards the
TASK_ID
task to the user provided by thetargetUser
query parameter.
- [PUT] /released
- Description
-
Releases the
TASK_ID
task.
- [PUT] /resumed
- Description
-
Resumes the
TASK_ID
task.
- [PUT] /skipped
- Description
-
Skips the
TASK_ID
task.
- [PUT] /suspended
- Description
-
Suspends the
TASK_ID
task.
- [PUT] /nominated
- Description
-
Nominates the
TASK_ID
task to the potential owners by thepotOwner
query parameter. You can use the parameter multiple times, for example:potOwner=usr1&potOwner=usr2
.
Example 16.5. Task Instances
Start task with
taskId
4 in the containertest
:$ curl -X PUT -u 'kieserver:kieserver1!' http://localhost:8080/kie-server/services/rest/server/containers/test/tasks/4/states/started
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'
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}']' 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>
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");
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"/>
See the source code for other possible values.
For the
props
value, specify the location of theapplication-roles.properties
file:<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" /> -->
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
:
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd"> <alternatives> <class>org.jbpm.services.cdi.producer.JAASUserGroupInfoProducer</class> </alternatives> </beans>
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
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_ID
task instance details.
- [POST] /attachments
- Request Type
- The content of the attachment.
- Response Type, Description
-
Adds a new attachment for the
TASK_ID
task. 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_ID
task.
- [GET] /attachments/ATTACHMENT_ID
- Response Type
- A TaskAttachment object.
- Description
-
Gets the
ATTACHMENT_ID
task attachment.
- [DELETE] /attachments/ATTACHMENT_ID
- Description
-
Removes the
ATTACHMENT_ID
task attachment.
- [GET] /attachments/ATTACHMENT_ID/content
- Response Type
- An attachment-type object.
- Description
-
Gets the
ATTACHMENT_ID
task attachment content.
- [POST] /comments
- Request Type
- A TaskComment object.
- Response Type
- Long.
- Description
-
Adds a new comment for the
TASK_ID
task. 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_ID
task.
- [GET] /comments/COMMENT_ID
- Response Type
- A TaskComment object.
- Description
-
Gets the
COMMENT_ID
task comment of theTASK_ID
task.
- [DELETE] /comments/COMMENT_ID
- Description
-
Deletes the
COMMENT_ID
task comment of theTASK_ID
task.
- [GET] /contents/input
- Response Type
- A map with the input parameters name and value.
- Description
-
Gets the
TASK_ID
task 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_ID
task 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_ID
task 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_ID
content and returns HTTP code 204.
- [PUT] /description
- Request Type
- Marshalled String value.
- Description
-
Updates the
TASK_ID
task 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_ID
task 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_ID
task 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_ID
task 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_ID
task propertyskipable
and 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'
Example response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-instance> <task-id>1</task-id> <task-priority>0</task-priority> <task-name>Approval by PM</task-name> <task-subject></task-subject> <task-description></task-description> <task-form>ApprovalbyPM</task-form> <task-status>Ready</task-status> <task-actual-owner></task-actual-owner> <task-created-by></task-created-by> <task-created-on>2016-02-15T13:31:10.624-02:00</task-created-on> <task-activation-time>2016-02-15T13:31:10.624-02:00</task-activation-time> <task-skippable>false</task-skippable> <task-workitem-id>1</task-workitem-id> <task-process-instance-id>1</task-process-instance-id> <task-parent-id>-1</task-parent-id> <task-process-id>com.sample.rewards-basic</task-process-id> <task-container-id>rewards</task-container-id> </task-instance>
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'
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'
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'
Example response:
{ "task-comment" : [ { "comment-id" : 1, "comment" : "Some task comment", "comment-added-by" : "kieserver" }, { "comment-id" : 3, "comment" : "One last comment", "comment-added-by" : "kieserver" } ] }
16.5. Querying Process Instances
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
<process-instance-list> <process-instance> <process-instance-id>4</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:23:29.428+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key/> <parent-instance-id>-1</parent-instance-id> </process-instance> <process-instance> <process-instance-id>5</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:40:39.772+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key/> <parent-instance-id>-1</parent-instance-id> </process-instance> </process-instance-list>
- [GET] processes/PROCESS_ID/instances
Returns a list of process instances for the specified process.
Additional parameters you can use:
status
,initiator
.Server Response
<process-instance-list> <process-instance> <process-instance-id>4</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:23:29.428+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key/> <parent-instance-id>-1</parent-instance-id> </process-instance> </process-instance-list>
- [GET] containers/CONTAINER_ID/process/instances
Returns a list of process instances for the specified container.
Additional parameters you can use:
status
.Server Response
<process-instance-list> <process-instance> <process-instance-id>4</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:23:29.428+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key/> <parent-instance-id>-1</parent-instance-id> </process-instance> <process-instance> <process-instance-id>5</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:40:39.772+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key/> <parent-instance-id>-1</parent-instance-id> </process-instance> </process-instance-list>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <process-instance> <process-instance-id>5</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:40:39.772+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key></correlation-key> <parent-instance-id>-1</parent-instance-id> <active-user-tasks> <task-summary> <task-id>5</task-id> <task-name>Self Evaluation</task-name> <task-description>Please perform a self-evalutation.</task-description> <task-priority>0</task-priority> <task-actual-owner>Kartik</task-actual-owner> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-05T09:40:39.778+02:00</task-created-on> <task-activation-time>2016-04-05T09:40:39.778+02:00</task-activation-time> <task-proc-inst-id>5</task-proc-inst-id> <task-proc-def-id>evaluation</task-proc-def-id> <task-container-id>myContainer</task-container-id> </task-summary> </active-user-tasks> </process-instance>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <process-instance-list> <process-instance> <process-instance-id>4</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:23:29.428+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key></correlation-key> <parent-instance-id>-1</parent-instance-id> </process-instance> <process-instance> <process-instance-id>5</process-instance-id> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <process-instance-state>1</process-instance-state> <container-id>myContainer</container-id> <initiator>kiesu</initiator> <start-date>2016-04-05T09:40:39.772+02:00</start-date> <process-instance-desc>Evaluation</process-instance-desc> <correlation-key></correlation-key> <parent-instance-id>-1</parent-instance-id> </process-instance> </process-instance-list>
- [GET] containers/CONTAINER_ID/processes/definitions
Returns a list of process definitions available for the container.
Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <process-definitions> <processes> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <package>Evaluation.src.main.resources</package> <container-id>myContainer</container-id> </processes> </process-definitions>
- [GET] processes/definitions
Returns list of process definitions.
Additional parameters you can use:
filter
.Note that the
filter
parameter filters all the process definitions that contain the given substring.Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <process-definitions> <processes> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <package>Evaluation.src.main.resources</package> <container-id>myContainer</container-id> </processes> </process-definitions>
- [GET] containers/CONTAINER_ID/processes/definitions/PROCESS_ID
Returns process definition of the specified process instance in the specified container.
Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <process-definitions> <processes> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <package>Evaluation.src.main.resources</package> <container-id>myContainer</container-id> </processes> </process-definitions>
- [GET] processes/definitions/PROCESS_ID
Returns a list of process definitions of the specified process.
Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <process-definitions> <processes> <process-id>evaluation</process-id> <process-name>Evaluation</process-name> <process-version>1</process-version> <package>Evaluation.src.main.resources</package> <container-id>myContainer</container-id> </processes> </process-definitions>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <node-instance-list> <node-instance> <node-instance-id>0</node-instance-id> <node-name> </node-name> <process-instance-id>5</process-instance-id> <container-id>myContainer</container-id> <start-date>2016-04-05T09:40:39.797+02:00</start-date> <node-id>_ED165B85-E65D-42A6-B0EF-8A160356271E</node-id> <node-type>StartNode</node-type> <node-connection>_B8F3E49D-2C7A-4056-BF49-C61987044DB4</node-connection> <node-completed>true</node-completed> </node-instance> <node-instance> <node-instance-id>1</node-instance-id> <node-name>Self Evaluation</node-name> <process-instance-id>5</process-instance-id> <work-item-id>5</work-item-id> <container-id>myContainer</container-id> <start-date>2016-04-05T09:40:39.773+02:00</start-date> <node-id>_D3E17247-1D94-47D8-93AD-D645E317B736</node-id> <node-type>HumanTaskNode</node-type> <node-connection>_B8F3E49D-2C7A-4056-BF49-C61987044DB4</node-connection> <node-completed>false</node-completed> </node-instance> <node-instance> <node-instance-id>0</node-instance-id> <node-name> </node-name> <process-instance-id>5</process-instance-id> <container-id>myContainer</container-id> <start-date>2016-04-05T09:40:39.772+02:00</start-date> <node-id>_ED165B85-E65D-42A6-B0EF-8A160356271E</node-id> <node-type>StartNode</node-type> <node-completed>false</node-completed> </node-instance> </node-instance-list>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <variable-instance-list> <variable-instance> <name>employee</name> <old-value></old-value> <value>Kartik</value> <process-instance-id>5</process-instance-id> <modification-date>2016-04-05T09:40:39.771+02:00</modification-date> </variable-instance> <variable-instance> <name>reason</name> <old-value></old-value> <value>Job Opening</value> <process-instance-id>5</process-instance-id> <modification-date>2016-04-05T09:40:39.771+02:00</modification-date> </variable-instance> </variable-instance-list>
- [GET] processes/instances/PROCESS_INSTANCE_ID/variables/instances/VARIABLE_NAME
Returns the value of the given variable in the specified process instance.
Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <variable-instance-list> <variable-instance> <name>employee</name> <old-value></old-value> <value>Kartik</value> <process-instance-id>5</process-instance-id> <modification-date>2016-04-05T09:40:39.771+02:00</modification-date> </variable-instance> </variable-instance-list>
16.6. Querying Tasks
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
user
filter is applicable only when the request is sent without authentication.Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-summary-list> <task-summary> <task-id>2</task-id> <task-name>Self Evaluation</task-name> <task-subject></task-subject> <task-description>Please perform a self-evalutation.</task-description> <task-status>Ready</task-status> <task-priority>0</task-priority> <task-is-skipable>false</task-is-skipable> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-05T15:09:14.206+02:00</task-created-on> <task-activation-time>2016-04-05T15:09:14.206+02:00</task-activation-time> <task-proc-inst-id>2</task-proc-inst-id> <task-proc-def-id>evaluation</task-proc-def-id> <task-container-id>myContainer</task-container-id> <task-parent-id>-1</task-parent-id> </task-summary> <task-summary> <task-id>1</task-id> <task-name>Self Evaluation</task-name> <task-subject></task-subject> <task-description>Please perform a self-evalutation.</task-description> <task-status>InProgress</task-status> <task-priority>0</task-priority> <task-is-skipable>false</task-is-skipable> <task-actual-owner>kiesu</task-actual-owner> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-05T15:05:06.508+02:00</task-created-on> <task-activation-time>2016-04-05T15:05:06.508+02:00</task-activation-time> <task-proc-inst-id>1</task-proc-inst-id> <task-proc-def-id>evaluation</task-proc-def-id> <task-container-id>myContainer</task-container-id> <task-parent-id>-1</task-parent-id> </task-summary> </task-summary-list>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-summary-list> <task-summary> <task-id>1</task-id> <task-name>Self Evaluation</task-name> <task-subject></task-subject> <task-description>Please perform a self-evalutation.</task-description> <task-status>InProgress</task-status> <task-priority>0</task-priority> <task-is-skipable>false</task-is-skipable> <task-actual-owner>kiesu</task-actual-owner> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-05T15:05:06.508+02:00</task-created-on> <task-activation-time>2016-04-05T15:05:06.508+02:00</task-activation-time> <task-proc-inst-id>1</task-proc-inst-id> <task-proc-def-id>evaluation</task-proc-def-id> <task-container-id>myContainer</task-container-id> <task-parent-id>-1</task-parent-id> </task-summary> </task-summary-list>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-event-instance-list> <task-event-instance> <task-event-id>1</task-event-id> <task-id>1</task-id> <task-event-type>ADDED</task-event-type> <task-event-user>evaluation</task-event-user> <task-event-date>2016-04-05T15:05:06.655+02:00</task-event-date> <task-process-instance-id>1</task-process-instance-id> <task-work-item-id>1</task-work-item-id> </task-event-instance> <task-event-instance> <task-event-id>1</task-event-id> <task-id>1</task-id> <task-event-type>STARTED</task-event-type> <task-event-user>kiesu</task-event-user> <task-event-date>2016-04-05T15:13:35.062+02:00</task-event-date> <task-process-instance-id>1</task-process-instance-id> <task-work-item-id>1</task-work-item-id> </task-event-instance> </task-event-instance-list>
- [GET] tasks/instances/TASK_INSTANCE_ID
Returns information about the specified task instance.
Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-instance> <task-id>1</task-id> <task-priority>0</task-priority> <task-name>Self Evaluation</task-name> <task-description>Please perform a self-evalutation.</task-description> <task-status>InProgress</task-status> <task-actual-owner>kiesu</task-actual-owner> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-05T15:05:06.508+02:00</task-created-on> <task-activation-time>2016-04-05T15:05:06.508+02:00</task-activation-time> <task-process-instance-id>1</task-process-instance-id> <task-process-id>evaluation</task-process-id> <task-container-id>myContainer</task-container-id> </task-instance>
- [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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-summary-list> <task-summary> <task-id>1</task-id> <task-name>Self Evaluation</task-name> <task-subject></task-subject> <task-description>Please perform a self-evalutation.</task-description> <task-status>InProgress</task-status> <task-priority>0</task-priority> <task-is-skipable>false</task-is-skipable> <task-actual-owner>kiesu</task-actual-owner> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-05T15:05:06.508+02:00</task-created-on> <task-activation-time>2016-04-05T15:05:06.508+02:00</task-activation-time> <task-proc-inst-id>1</task-proc-inst-id> <task-proc-def-id>evaluation</task-proc-def-id> <task-container-id>myContainer</task-container-id> <task-parent-id>-1</task-parent-id> </task-summary> </task-summary-list>
- [GET] tasks/instances/variables/VARIABLE_NAME
Returns a list of tasks that use the specified variable.
Aditional parameters you can use:
varValue
,status
,user
.<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-summary-list> <task-summary> <task-id>1</task-id> <task-name>Self Evaluation</task-name> <task-subject>Please perform a self-evalutation.</task-subject> <task-description>Please perform a self-evalutation.</task-description> <task-status>Ready</task-status> <task-priority>0</task-priority> <task-is-skipable>false</task-is-skipable> <task-created-by>Kartik</task-created-by> <task-created-on>2016-04-07T13:40:32.181+02:00</task-created-on> <task-activation-time>2016-04-07T13:40:32.181+02:00</task-activation-time> <task-proc-inst-id>1</task-proc-inst-id> <task-proc-def-id>evaluation</task-proc-def-id> <task-container-id>myContainer</task-container-id> <task-parent-id>-1</task-parent-id> </task-summary> </task-summary-list>
16.7. Advanced Queries for the Intelligent Process Server
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
{ "query-name" : "getAllTaskInstancesWithCustomVariables1", "query-source" : "java:jboss/datasources/ExampleDS", "query-expression" : "select ti.*, c.country, c.productCode, c.quantity, c.price, c.saleDate from AuditTaskImpl ti inner join (select mv.map_var_id, mv.taskid from MappedVariable mv) mv on (mv.taskid = ti.taskId) inner join ProductSale c on (c.id = mv.map_var_id)", "query-target" : "CUSTOM" }
- [PUT] /QUERY_NAME
- This endpoint updates a query definition.
Request Body
{ "query-name" : "getAllTaskInstancesWithCustomVariables1", "query-source" : "java:jboss/datasources/ExampleDS", "query-expression" : "select ti.*, c.country, c.productCode, c.quantity, c.price, c.saleDate from AuditTaskImpl ti inner join (select mv.map_var_id, mv.taskid from MappedVariable mv) mv on (mv.taskid = ti.taskId) inner join ProductSale c on (c.id = mv.map_var_id)", "query-target" : "CUSTOM" }
- [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
{ "order-by" : "saleDate, country", "order-asc" : false, "query-params" : [ { "cond-column" : "processInstanceId", "cond-operator" : "BETWEEN", "cond-values" : [ 1000, 2000 ] }, { "cond-column" : "price", "cond-operator" : "GREATER_THAN", "cond-values" : [ 800 ] }, { "cond-column" : "saleDate", "cond-operator" : "BETWEEN", "cond-values" : [ {"java.util.Date":1454281200000}, {"java.util.Date":1456786800000} ] }, { "cond-column" : "productCode", "cond-operator" : "IN", "cond-values" : [ "EAP", "WILDFLY" ] } ], "result-column-mapping" : { "PRICE" : "double", "PRODUCTCODE" : "string", "COUNTRY" : "string", "SALEDATE" : "date", "QUANTITY" : "integer" } }
- [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 }
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:
<query-definition> <query-name>getAllTasks</query-name> <query-source>java:jboss/datasources/ExampleDS</query-source> <query-expression>select * from Task t</query-expression> <query-target>TASK</query-target> </query-definition>
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'
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'
Server Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <task-instance-list> <task-instance> <task-priority>0</task-priority> <task-name>TEST_HT</task-name> <task-description></task-description> <task-status>Reserved</task-status> <task-created-on>2016-05-14T01:47:42.684-03:00</task-created-on> <task-activation-time>2016-05-14T01:47:42.684-03:00</task-activation-time> <task-process-instance-id>1</task-process-instance-id> <task-process-id>project1.proc_ht</task-process-id> <task-container-id>project1</task-container-id> </task-instance> </task-instance-list>
16.8. Managing Job Execution
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
RequestInfoInstance
objectsDescription: 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:
RequestInfoInstance
objectResponse type: created
JOB_ID
Description: 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
RequestInfoInstance
objectsDescription: Returns a list of jobs configured to run with the
JOB_COMMAND_NAME
command class.- [GET] /JOB_ID
Response type:
RequestInfoInstance
objectDescription: Returns details of a job request with the provided
JOB_ID
. You can specify the parameterswithErrors
(boolean) to include errors of an execution andwithData
to 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:
RequestInfoInstance
objectDescription: Requests unfinished or failed job request with the given
JOB_ID
and reassigns it into the job queue.- [GET] /keys/BUSINESS_KEY
Response type: list of
RequestInfoInstance
objectsDescription: 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.xml
file with the following content:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <job-request-instance> <job-command>org.jbpm.executor.commands.PrintOutCommand</job-command> <scheduled-date>2016-02-11T00:00:00-02:00</scheduled-date> <data /> </job-request-instance>
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/'
An example response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <long-type> <value>4</value> </long-type>
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'
An example response:
{ "request-info-instance" : [ { "request-instance-id" : 3, "request-status" : "CANCELLED", "request-message" : "Ready to execute", "request-retries" : 3, "request-executions" : 0, "request-command" : "org.jbpm.executor.commands.PrintOutCommand", "request-scheduled-date" : 1455156000000 }, { "request-instance-id" : 2, "request-status" : "QUEUED", "request-message" : "Ready to execute", "request-retries" : 3, "request-executions" : 0, "request-command" : "org.jbpm.executor.commands.PrintOutCommand", "request-scheduled-date" : 1454983200000 }, { "request-instance-id" : 1, "request-status" : "DONE", "request-message" : "Ready to execute", "request-retries" : 3, "request-executions" : 0, "request-command" : "org.jbpm.executor.commands.PrintOutCommand", "request-scheduled-date" : 1454918401190 } ] }