我正在尝试使用 php-curl 并使用 header 作为 multipart/form-data 从 oracle bi 发布者获取响应,但结果是请求失败
我还尝试直接从邮递员那里获取代码,因为它可以正常工作,但也会导致请求失败
请帮忙修复代码
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'HOST:PORT/xmlpserver/services/rest/v1/reports/OBTF%2Frapport%2FECHANCE%20LC%2Fapi2/run'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array('ReportRequest' => '{\"attributeFormat\":\"html\",\"attributeTemplate\":\"Publisher Template\"}')); curl_setopt($ch, CURLOPT_USERPWD, 'login' . ':' . 'password'); $headers = array(); $headers[] = 'Content-Type: multipart/form-data'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } echo $result; curl_close($ch);
@CBroe
雷雷