Jira Attachment URL from Jira API ( not REST ) - how take? Edited

Hi Guys.

Is there any why to take URL ( download link ) to attachment via Jira-API (java) - not rest ?

Regards

Mik

1 answer

This widget could not be displayed.
Alexey Matveev Community Champion Nov 09, 2017

Hello,

I am not sure what you want.

If you want to find attachment path then the code would be like this

Issue issueKey = issue
def id = issueKey.getId()

// Get the current logged in user
def user = ComponentAccessor.getJiraAuthenticationContext().getUser().name

// Get a manager to handle the copying of attachments
def attachmentManager = ComponentAccessor.getAttachmentManager()

// Get the default attachment path from its manager 
def attachmentPathManager = ComponentAccessor.getAttachmentPathManager().attachmentPath.toString()

// Get the current date
// Construct the key of the next Subtask
def currentIssue = issue.toString()

// Extract the project key from the issue
def projectKey = currentIssue.replaceAll("[^A-Z]", "").toString();

// Get the ID that jira has used to store the last attachment
def fileId = issueKey.attachments.last()?.id

// Construct the file path of the attachment to copy
def path = attachmentPathManager + "/" + projectKey + "/" + currentIssue + "/" + fileId + "/"

 It was taken from here

https://community.atlassian.com/t5/Jira-Core-questions/How-can-I-copy-the-last-attachment-from-a-Jira-issue-to-another/qaq-p/145363

If it does not answer your question, kindly clarify it.

Groovy directive, short for "define".  It creates (untyped) variables in a script.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

269 views 5 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you