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
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 ;-)))
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.