Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Mik
Contributor
November 9, 2017 edited

Hi Guys.

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

Regards

Mik

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 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.

Gabriel Rojas June 13, 2018

what is def?

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2018

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

Gabriel Rojas June 13, 2018
Like • Ivan likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events