Forums

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

.NET SDK can't download attachments from issues

Khai Minh Mai April 3, 2025

Hi everyone,

I'm trying to use this Atlassian SDK

NuGet Gallery | Atlassian.SDK 13.0.0

to download attachments from Jira cloud issues using:

var attachments = await issue.GetAttachmentsAsync();

foreach (Attachment attachment in attachments) {
   var content = attachment.DownloadData();
// Save the attachment locally for testing
  File.WriteAllBytes(Path.Combine("path_to_folder", attachment.FileName), content);

}

the attachments are already correctly recognized and downloaded, with the correct names and file types, but when I open these attachments (using Notepad), only this message is shown:

{"errorMessages":["You do not have permission to view attachment with id: 16533"],"errors":{}}

according to the Documentation

farmas / atlassian.net-sdk README.md — Bitbucket

there is also this alternative:

 

// get attachments
var attachments = await issue.GetAttachmentsAsync();
Console.WriteLine(attachments.First().FileName);

// download an attachment
var tempFile = Path.GetTempFileName();
attachments[0].Download(tempFile);

which will create a temp file for the downloaded byte array. But there I also found the same error saying I do not have the permission.

For context: I'm currently using the Web API Token to create the REST client. Could it be that I have to set up OAuth for this use case?

Thanks in advance, and wish you all a nice weekend.

P/S: Screenshot of the error message

Screenshot 2025-04-03 115629.png

1 answer

1 accepted

1 vote
Answer accepted
Khai Minh Mai April 7, 2025

I worked around the issue with a direct GET request to {jira_url}/rest/api/3/attachment/content/{attachment_id} using .NET's built-in HttpClient. Hope this get fixed by the dev though, since its looking messy ;-)))

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events