我试图通过rest使用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.1rn".
"Host: bonita.libertypr.comrn".
"Cookie: ". $display[1]."rn".
"Content-Type: application/jsonrn" .
"Accept: application/jsonrn".
"Cache-Control: no-cachern".
"Pragma: no-cachern".
"Connection: Keep-Alivernrn",
"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);
在调用此API调用之前,请确保您在Bonita端进行了身份验证。请参阅此链接了解更多详情:http://documentation.bonitasoft.com/rest-api-overview验证
如果不是,Bonita API调用将被拒绝。
为了进一步分析导致问题的原因,您应该掌握在代码和Bonita之间发送的HTTP请求和响应。为此,可以使用Wireshark
等工具捕获HTTP流量。欢呼,