Downloading issue attachment in scriptrunner cloud

Hi guys!

I have to change issue attachement name using scriptrunner in jira Cloud. Got all data in issueUpdated listener. Now i have to download the file using script.

Is there any way to download issue attachment as InputStream using Jira Cloud Rest API?

Already tried just fetch it using URI:

InputStream input = new URL(it.content).openStream();

But then i got authorisation error.

I figured it out. From listener context got the attachment URL, then was able to download file using below function:

public InputStream getAttachmentFile(String attachmentPatch){
    def response = get(attachmentPatch)
    .header("Accept", "application/json; charset=UTF-8")
        return null

    return response.getRawBody()

1 Like