我正在使用Jira rest API创建附件问题。我已经成功创建了带有摘要和描述的问题单,但是在添加带有Jira问题的附件时遇到了问题。
如何在PHP curl请求中使用rest API向Jira问题添加附件?
我正在使用此代码添加附件。
$url = 'https://domain.atlassian.net/rest/api/2/issue/PL-113/attachments';
$fileLocation = 'D:/xampp/htdocs';
$fileName = 'test.jpg';
$username = 'username';
$password = 'password';
$data = array('file'=>"@{$fileLocation};filename={$fileName}");
$headers = array(
'X-Atlassian-Token: nocheck'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($curl);
$ch_error = curl_error($curl);
if ($ch_error) {
echo "cURL Error: $ch_error";
} else {
echo $result;
}
curl_close($curl);
预先感谢