The following approval-related operations are currently available via REST service:
- starting an approval process,
- determining the status of the approval process.
The following is doable, but currently only using an unsupported "hack", basically for demonstration purposes only:
- approving or rejecting an item (i.e. the actual decision making).
In this document we'll show how to carry out these operations.
Starting an approval process
In midPoint the approval process is started automatically when an operation requiring approval is started. I.e. there's no special "start an approval process" method.
Let us illustrate this on an example.
This is user
This is role
sensitive that we want to assign to
The role has an approver, named
Paul has an assignment to role
sensitive with a relation of
approver, so it is an approver for all assignments of that role.
Now let's start the approval process. We will do that by assigning role
special to user
The above XML is sent to the REST service and it will be applied (as an object delta) to object
peter. It has one item delta, in particular creation of an assignment to
d4930444-c5e5-4710-af96-19f79eb078cb i.e. to the
The response is then like this:
I.e. the operation was successful.
Determining the status of the approval process
The approval processes are represented as case objects. So they can be retrieved just like any other using the REST search operation. An example:
The above search query returns all approval processes and the whole requests that deal with the user
peter and are still waiting to be resolved (state=open condition).
state is an URI. It can have both unqualified and qualified forms, e.g.
. In theory, you would need to check for both, using e.g. OR filter clause. But practically, midPoint currently uses the unqualified form. #open
There are two kinds of approval-related cases:
- Operation-level cases, covering the whole operation. Each operation can consist of one or more elementary actions, like "add assignment to role R1", "add assignment to role R2", "remove assignment of role R3". Operation cases have the
- Individual approval cases; each covering a single elementary action, like "add assignment to role R1". Each such task corresponds to a single approval process. These have the
You can use a filter on
archetypeRef to differentiate between these two kinds; returning only what you need.
Approving or rejecting a work item
It is currently not possible to approve or reject a work item via REST directly. And it never was. As described here there was always an unsupported "hack" that allowed it. The following is an attempt to port that hack to 4.x. DO NOT USE THIS in production.
This is a missing or incomplete feature of midPoint and/or of other related components. We are perfectly capable to implement, fix and finish the feature, just the funding for the work is needed. Please consider the possibility for supporting development of this feature by means of midPoint Platform subscription. If you already are midPoint Platform subscriber and this feature is within the goals of your deployment you may be able to use your subscription to endorse implementation of this feature.
Having understood the above, let us describe the hack. This will approve the work item:
(--data-binary is there because otherwise the lines in script got concatenated, at least sometimes on Windows)
Unfortunately, the approval/rejection is logged under
administrator account. It is not possible to use non-admin account to carry out this action, because Groovy script execution requires the strongest authorization (because of the security implications). But, as said, this is more-or-less for demonstration purposes.