Nous utilisons HP Quality Center et nous améliorons 11.5x à 12.21 et j'utilise l'API pour créer un ticket. La connexion et la création de ticket sont correctes, mais l'attachement du fichier ne l'est pas.API QC REST: Type de support non pris en charge
J'obtenu {"Id":"qccore.general-error","Title":"Unsupported Media Type","ExceptionProperties":null,"StackTrace":null}
Voici mon code
$filename = $file->name;
$eol = "\r\n";
$mime_boundary = 'boundary';
$content = '--' . $mime_boundary . $eol;
$content .= 'Content-Disposition: form-data; name="entity.type"';
$content .= $eol . $eol;
$content .= 'defect';
$content .= $eol;
$content = '--' . $mime_boundary . $eol;
$content .= 'Content-Disposition: form-data; name="entity.id"';
$content .= $eol . $eol;
$content .= $id;
$content .= $eol;
$content = '--' . $mime_boundary . $eol;
$content .= 'Content-Disposition: form-data; name="filename"';
$content .= $eol . $eol;
$content .= utf8_encode($filename);
$content .= $eol;
$content .= '--' . $mime_boundary . $eol;
$content .= 'Content-Disposition: form-data; name="file"; filename="' . utf8_encode($filename) . '"';
$content .= $eol;
$content .= 'Content-Type: ' . $file['type'];
$content .= $eol . $eol;
$dt = explode('-', $file->create_dt);
$path_file = $config['files']['forms_attachments_path'] . DIRECTORY_SEPARATOR . $dt[0] . DIRECTORY_SEPARATOR . $dt[1] . DIRECTORY_SEPARATOR . $file->filename;
$handle = fopen($path_file, 'r');
$content .= fread($handle,filesize($path_file));
fclose($handle);
$content .= $eol;
$content .= '--' . $mime_boundary . '--';
$header = array(
'Content-Type: multipart/mixed; boundary='.$mime_boundary,
'Content-Length: '.strlen($content),
'Accept: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_COOKIE, $cookiess);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_PROXY, null);
curl_setopt($ch, CURLOPT_URL, $config['qc']['url'] . '/api/domains/' . $config['qc']['domain']. '/projects/' . $config['qc']['project'] . '/attachments/');
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
Si j'utilise l'autre multipart/form-data i obtenu {"Id":"qccore.general-error","Title":"Illegal multi-part arguments. Attachment wasn't created.","ExceptionProperties":null,"StackTrace":null}
j'ai donc une erreur structure multipart ou une mauvaise tête pour le type de contenu, mais tout ce que nous testons échoue.
Nous essayons de mettre la pièce jointe par la méthode du flux d'octets mais obtenons l'erreur de type de support.
Merci pour votre aide,