Heim  >  Fragen und Antworten  >  Hauptteil

Die mehrteilige/Formulardatenanforderung von PHPcurl ist fehlgeschlagen

Ich versuche, eine Antwort vom Oracle Bi Publisher zu erhalten, indem ich PHP-Curl verwende und den Header als Multipart-/Formulardaten verwende, aber das Ergebnis ist Anfrage fehlgeschlagen

Ich habe auch versucht, den Code direkt vom Postboten zu bekommen, da er gut funktionierte, aber auch dazu führte, dass Anfragen fehlschlugen

Bitte helfen Sie, den Code zu beheben

<?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);

P粉331849987P粉331849987233 Tage vor449

Antworte allen(1)Ich werde antworten

  • P粉903969231

    P粉9039692312024-02-04 21:03:20

    @CBroe

    CURLOPT_URL => 'http://HOST:PORT/xmlpserver/services/rest/v1/reports/OBTF%2Frapport%2FECHANCE%20LC%2Fapi2/run',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_SSL_VERIFYPEER=> false,
      CURLOPT_HEADER=> FALSE,
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS => array("ReportRequest"=>'{"attributeFormat":"html","attributeTemplate":"Publisher Template"}'),
      CURLOPT_HTTPHEADER => array(
     'Content-Type: multipart/form-data;boundary=--Boundary_4_543972006_1465550732054--','Content-Length:1'
      ),
    ));```

    Antwort
    0
  • StornierenAntwort