Jira 케이스에 API를 사용하여 파일을 첨부하려고합니다. Drupal 6 (PHP v.5.0)에서이 작업을 수행하고 있습니다.Jira의 api에 첨부 파일 추가하기
$ch = curl_init();
$header = array(
'Content-Type: multipart/form-data',
'X-Atlassian-Token: no-check'
);
$attachmentPath = $this->get_file_uploads();
//$attachmentPath comes out to be something like:
//http://localhost/mySite/web/system/files/my_folder/DSC_0344_3.JPG
$data = array('file'=>"@". $attachmentPath, 'filename'=>'test.png');
$url= 'https://mysite.atlassian.net/rest/api/2/issue/20612/attachments/';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->get_jira_headers());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS ,$data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");
$result = curl_exec($ch);
$ch_error = curl_error($ch);
문제는 $ 결과가 거짓으로 나온다하고 $ ch_error이 파일을 열 수 없다는 주장이다 : 여기 내가 가지고있는 코드입니다. 이 오류는 Drupal과 관련이 있거나 Jira에게 요청하는 방법과 관련이 있습니까? BTW, 절대 경로를 사용하는 경우 다음과 같이하십시오.
$attachmentPath = 'C:\wamp\www\mySite\web\sites\mySite.net\files\my_folder\DSC_0333.JPG';
업로드가 올바르게 작동합니다.
감사합니다. 나는 실제로 우연히이 질문에 현상금을 추가했다. 내가 추가 한 다른 질문에 덧붙이려고했다. 그러나, 거래는 거래이고 나는 단지 그것이 작동하기 때문에 기쁘다! – jason
@jason 환영합니다! 그래, 내 생각에 그것이 작동하게하는 주된 목표라고 생각해! – Rizier123
그것은 cURL 오류를 반환합니다 : 형식이 잘못되었습니다. –