Forums

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

How I can download issue attachments from JIRA using java code ?

Nilesh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 14, 2019
import java.util.Iterator;

// Get details of a given JIRA Issue
public class Test3
{
public static void main(String[] args) throws IOException
{


URI jiraServerUri = URI.create("http://localhost:8080");

AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();

JiraRestClient restClient = factory.create(jiraServerUri, new BasicHttpAuthenticationHandler("user", "password"));
IssueRestClient issueClient = restClient.getIssueClient();

try
{
Issue issue = issueClient.getIssue("DEMO-123").claim();




Iterator<BasicComponent> allComponents = issue.getComponents().iterator();
while (allComponents.hasNext())
{
BasicComponent component = allComponents.next();
System.out.println("Component : " + component.getName());
}

Iterator<String> allLabels = issue.getLabels().iterator();
while (allLabels.hasNext())
{



Iterator<Attachment> attachments = issue.getAttachments().iterator();
while (attachments.hasNext())
{
Attachment attachment = attachments.next();
System.out.println("Attachment : " + attachment.getFilename());
}
} finally {
restClient.close();
}

}
}

I am getting the attachment name from this code but how can I download the attachment in my local machine ?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Thomas Deiler
Community Champion
July 15, 2019

Dear @Nilesh ,

please reopen your question at https://community.developer.atlassian.com/ again. There is the right audience to help you.

Thanks for understanding

Thomas