I'm trying to extract image content from Jira using the REST API. Using the 'attachment' field I can get all the meta data about the image, including filename, size,mimeType, content Url, thumbnail url etc.
But I need to be able to download the image itself. Putting the content url into a browser downloads the image ok, but only because I happen to logged into Jira.
So I'm using PHP CURL to download the image from this url and I'm hoping that the following code should do it:
$ch = curl_init($url);
$tempPath = '/tmp/jira_' . uniqid(true) ;
$fp = fopen($tempPath, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_USERPWD, "firstname.lastname@example.org:$this->_apiKey" );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
I'm using the CURLOPT_USERPWD in the same way I do when using the rest API, but the file is always empty. I'm assuming that this is an authentication issue. Can anybody tell me how I am supposed to authenticate?
For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events