I'm trying to upload a file through Jira Service Desk's API using the /servicedeskapi/servicedesk/{serviceDeskId}/attachTemporaryFile method as described here: https://docs.atlassian.com/jira-servicedesk/REST/3.9.1/#servicedeskapi/servicedesk/{serviceDeskId}/attachTemporaryFile . This is my code:
<?php
$fileToUpload = '/var/www/html/test.txt';
$cFile = new CURLFile($fileToUpload, 'text/plain', 'test.txt');
$headers = [
'Accept: application/json',
'Authorization: Basic ....',
'X-Atlassian-Token: no-check',
'Content-Type: multipart/form-data',
'X-ExperimentalApi: opt-in',
'Content-Length: '.filesize($fileToUpload)
];
$post = array('file' => $cFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://example.com/rest/servicedeskapi/servicedesk/27/attachTemporaryFile');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
curl_close($ch);
However, I keep getting the following error message:
{"errorMessage":"No attachments found.","i18nErrorMessage":{"i18nKey":"sd.attachment.empty.error","parameters":[]}}
With a 400 HTTP status code in response.
What am I missing? I read it might have something to do with rfc2388 but I couldn't figure out what the issue is.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.