gnustavo / JIRA-REST

Thin wrapper around Jira's REST API
https://metacpan.org/release/JIRA-REST/
17 stars 17 forks source link

Attachment download #26

Closed jlruedab closed 1 year ago

jlruedab commented 2 years ago

Hi Trying to download an attachemnt from a JIRA issue like this:

$jira->GET("https://jira.somedomain.com/secure/attachment/41410/SSS_2022-03-31.tgz.gpg");

but I'm getting this error:

JIRA::REST Error[500 - Internal Server Error]: I don't understand content with Content-Type 'application/octet-stream;charset=UTF-8'.

Wonder if I'm doing something wrong?

gnustavo commented 2 years ago

Hi @jlruedab. You can't use the JIRA::REST::GET method to download attachments because it expects to get an application/json result but the attachment is an application/octet-stream. I just released v0.022 of JIRA::REST which contains a new example script showing how can you download attachments: download_attachment.pl.

Take a look at lines 39-48.

Note that is uses the JIRA::REST::rest_client method to obtain the REST::Client object, which is new on v0.022. If you can't upgrade JIRA::REST to the new version you can replace $jira->rest_client by $jira->{rest} on line 45.

Tell me if it works for you.