The Light endpoints are deprecated and they aren't going to be fixed. I have created a new REST endpoint that you can use in my extraRest plugin:
(39 KiB) Downloaded 263 times
Go to
Admin > Plugins > Plugin Manager and click on "Import". After importing the
extraRest-1.tar file, then enable the plugin.
Here is the endpoint:
POST http://{domain-or-ip}/api/1.0/workflow/extrarest/case/{app_uid}/claim
POST parameters:
parameter | Description |
del_index | Optional. The delegation index of the task to claim. Only needs to be included if there are multiple open tasks in the case. |
usr_uid | Optional. Unique ID of the user to assign to case. Only include if the logged-in user is a process supervisor assigning another user. |
Response:
None if successful.
Examples:
Code: Select all //assigning logged-in user to a Self Service Task where there is only one open task in case:
$caseId = '2554682895ac25995666e24055342045';
$url = "/api/1.0/workflow/extrarest/case/$caseId/claim";
$aVars = array();
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
//assigning logged-in user to a Self Service Task where there are 2 open tasks in case:
$caseId = '2554682895ac25995666e24055342045';
$url = "/api/1.0/workflow/extrarest/case/$caseId/claim";
$aVars = array(
'del_index' => 3
);
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
//assigning another user to Self Service Task when logged-in user is a Process Supervisor:
$caseId = '2554682895ac25995666e24055342045';
$url = "/api/1.0/workflow/extrarest/case/$caseId/claim";
$aVars = array(
'del_index' => 2,
'usr_uid' => '10654575559caec5e953104064429578' //unique ID of user to assign to task
);
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
Here is the code of the endpoint, in case you want to modify it:
Code: Select all /**
* Claim a case for the logged-in user where a task is unassigned because the task
* is Self Service or Self Service Value Based Assignment.
*
* @url POST /case/:app_uid/claim
* @access protected
*
* @param string $app_uid Case unique ID. {@from path}{@min 1}{@max 32}
* @param int $del_index Optional. The delegation index of the task to claim.
* Only include if there are multiple open tasks in the case. {@from body}
* @param string $usr_uid Optional. Unique ID of the user to assign to case.
* Only include if the logged-in user is a process supervisor assigning another user {@from body}
*/
public function postClaimCase($app_uid, $del_index = null, $usr_uid = null)
{
try {
$loggedUserId = $this->getUserId();
$oCase = new \Cases();
if (empty($del_index)) {
$del_index = $oCase->getCurrentDelegation($app_uid, '', true);
}
$oAppDel = new \AppDelegation();
$aDelegation = $oAppDel->load($app_uid, $del_index);
if ($aDelegation['USR_UID'] != '') {
throw new \Exception("The task is already assigned to user with ID '{$aDelegation['USR_UID']}'.");
}
if (empty($usr_uid) or $loggedUserId == $usr_uid) {
$userIdToAssign = $loggedUserId;
}
else {
//check whether the user exists and has the PM_SUPERVISOR permission in role.
$rbac = \RBAC::getSingleton();
$rbac->initRBAC();
if ($rbac->verifyUserId($usr_uid) != 1) {
throw new \Exception("User with ID '$usr_uid' does not exist.");
}
if ($this->userCanAccess('PM_SUPERVISOR') == 0) {
throw new \Exception("Logged-in user lacks the PM_SUPERVISOR permission in role.");
}
//check if logged-in user is assigned as a process supervisor to the process
$oSuper = new \ProcessMaker\BusinessModel\ProcessSupervisor();
$aSupervisorList = $oSuper->getProcessSupervisors($aDelegation['PRO_UID'], 'ASSIGNED');
if (!isset($aSupervisorList['data']) or !is_array($aSupervisorList['data'])) {
throw new \Exception("Unable to retrieve list of supervisors for process.");
}
$isSuperForProcess = false;
foreach ($aSupervisorList['data'] as $aSupervisorInfo) {
if ($aSupervisorInfo['usr_uid'] == $loggedUserId) {
$isSuperForProcess = true;
break;
}
}
if ($isSuperForProcess === false) {
throw new \Exception("User '$loggedUserId' must be assigned as a Supervisor for process '".
$aDelegation['PRO_UID']."'.");
}
$userIdToAssign = $usr_uid;
}
return $oCase->setCatchUser($app_uid, $del_index, $userIdToAssign);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}