2017-10-04 84 views
0

我使用camunda_bpm_apigit url和drupal8 camunda+drupal8 sample module模块)模块在Drupal我的自定义应用程序连接到服务器camunda。检索任务列表分配给特定用户camunda

我所用的功能如下检索process definitions

private function fetchProcessDefinitions() { 
    return \Drupal::service('camunda_bpm_api.process_definition')->getList(); 
    } 

这是正常工作。

我如何检索分配给特定用户的任务?我试图如下:

public function fetchTaskList() { 
    $payload = array('assignee' => 'nimyav'); 
    return \Drupal::service('camunda_bpm_api.task')->getList($payload); 
} 

但其retriveing all the tasks不论assignee

我该如何做到这一点?任何帮助表示赞赏。

回答

2

只是为了仔细检查您是否获得了结果,如果您打电话curl -X GET "http://localhost:8080/engine-rest/engine/default/task?assignee=nimyav" -H "accept: application/json",假设您的BPM工程已在本地安装,会发生什么情况?如果您不使用卷曲,则可以使用网址http://localhost:8080/engine-rest/engine/default/task?assignee=nimyav打开浏览器。你看到只分配给你的任务吗?

通常,您的请求似乎没问题,但是没有将第二个参数传递给您在HTTP GET模式下使用的getList()。如果你看看Camunda REST docs,你会注意到一些方法可用作GET和POST方法。特别是,我相信Valentin设计的getList方法在HTTP POST模式下工作,因为它正在请求主体中传递参数(请查阅camunda_bpm_api/src/BPMPlatform/BaseService.php了解更多详细信息)。

请尝试调用该服务是这样的:

public function fetchTaskList() { 
    $payload = array('assignee' => 'nimyav'); 
    $usePost = TRUE; 
    return \Drupal::service('camunda_bpm_api.task')->getList($payload, $usePost); 
} 
+0

我猜中了。谢谢 :) 。另一个问题**如何通过其余API API获取任务进程的表单变量?当我尝试** http:// localhost:8080/engine-rest/engine/default/task/0ce473ad-a922-11e7-bc26-005056a64ad8/form-variables **它获得一个json,不包含给定的表单变量在表单提交中。 – Crazyrubixfan

+0

嗨,它也可以使用像返回**公共函数getTaskVariables($ id,数组$变量,$ businessKey = NULL){ 返回$ this-> request('get',array(),'/ process-instance /' 。$ id。'/ variables'); } ** 正在通过** http://192.168.1.188:8080/engine-rest/process-instance/e78f1bd3-a921-11e7-bc26-005056a64ad8 /变量获取响应** – Crazyrubixfan

相关问题