-1

我正在尝试使用 HTTP 请求通过休息向 BonitaBPM 发送文件,但是当我使用文件获取内容时,我尝试发送的文件为空,并且 HTTP 请求显然无法正常工作

$file_contents = file_get_contents("C:/inetpub/wwwroot/upload/Director.png"); 
$data1 = array(
    "caseId"=> $case_id[1],
    "file"=>"C:/inetpub/wwwroot/upload/Director.png",
    "name"=>"doc_invoice",
    "fileName"=> $_FILES['file_attach']['name'],
    "description"=> "Invoice"
);
//Structure of process data to start case
$options1 = array(
    "http" => array(
        "method"  => "POST",
        "header"=>  "POST /bonita/API/bpm/caseDocument  HTTP/1.1\r\n".
            "Host: bonita.libertypr.com\r\n".
            "Cookie: ". $display[1]."\r\n".
            "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n".
            "Cache-Control: no-cache\r\n".
            "Pragma: no-cache\r\n".
            "Connection: Keep-Alive\r\n\r\n",
        "content" => json_encode($data1)
    )
);
//decode process data and adds document to case
$url1 = "http://bonita.libertypr.com:8081/bonita/API/bpm/caseDocument";
$context1  = stream_context_create($options1);
$result1 = file_get_contents($url1, false, $context1);
$response1 =  json_decode($result1);
4

1 回答 1

0

在调用此 API 调用之前,请确保您在 Bonita 端进行了身份验证。有关更多详细信息,请参阅此链接: http ://documentation.bonitasoft.com/rest-api-overview#authentication

否则,Bonita API 调用将被拒绝。

要进一步分析导致问题的原因,您应该了解代码和 Bonita 之间发送的 HTTP 请求和响应。为此,您可以使用Wireshark等工具捕获 HTTP 流量

干杯,

于 2015-05-21T14:28:42.430 回答