Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Downloading xlsx or png from Jira via API creates corrupted file

I am using the Jira api to pull down attachments from our Jira Server instance. I am finding the files I pull down and save are corrupted if they are anything but txt files.  
Below is my code fragment that works for pulling down txt files:
String url = "https://" + serverName + "/rest/api/2/attachment/" + attId;
String response = executeGet(url, false);
if (response != null){
JsonUtil ju = new JsonUtil(response, false);
org.json.simple.JSONObject attachmentInfo = ju.getJsonMessage();
String mimeType = (String)attachmentInfo.get("mimeType");
String contentUrl = (String)attachmentInfo.get("content");
String filename = (String)attachmentInfo.get("filename");
try {
URL fileUrl = new URL(contentUrl);
try (InputStream in = fileUrl.openStream()) {
Files.copy(in, Paths.get(filename));
} catch (Exception e) {
logger.error("Unable to download file from " + contentUrl);
I have used the File.copy before to pull down pngs from the other sites with no problem. Any advice would be great.

2 answers

1 accepted

0 votes
Answer accepted

I was able to resolve the issue, I changed to code to use URLConnection instead of HTTPConnection and that worked

0 votes
Dan Breyen
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.
May 10, 2023

 Hi David, I looked in Atlassian's JIRA site and didn't find anything specific to this issue (either open or closed).  In the future, you can search their site for issues at  If you can replicate it(and it sounds like you can), I would enter a support ticket with atlassian at and see what they say.  I know it's server, so I'm not sure if they'll fix it or not.  They also might know of a version that there is a fix in, as I see you're not on the latest code.

Thanks for the advice, I have done so, I typically double up my requests bc the Community is usually quicker than support.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events