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

Jira REST API view/download attachments

Matteo Cominetti October 22, 2013

Hello, I'm wirting a C# app that talks with Jira using REST API 6. I manage to do everything I want, but when I try to display images (using their URL) attached to Issues I cannot do that, because the "user" (my app) is not logged in.

So, is there a way to get the attachments as binary data, or a way to bypass autenthication for attachments? Or to get the real full URL from the server?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Matteo Cominetti October 24, 2013

Ok, I figured out it by myself!

Stupid mistake: I just didn't understand that I needed to request the file with another GET request and then decode the stream to file!!

using (var sw = new StreamWriter(@"path-to-where-i-want-to-save-the-file"))
                        {
                            sw.Write(Encoding.UTF8.GetString(response.RawBytes.ToArray()));
                        }


jdafielmoto-admin July 20, 2014

hi, can you provide sample for this? thanks

Matteo Cominetti July 20, 2014

Hey, have a look to this ValueConverter I wrote:

http://pastebin.com/be9EqacN#

jdafielmoto-admin July 20, 2014

thanks this is a big help. What we want is download all attach files in the issue.

Kevin Mauriello February 17, 2017

What is the get you are using to retrieve the binary data?  I cannot find a REST call to get that information

0 votes
jdafielmoto-admin July 20, 2014

Hi, Can yo provide a sample on how to download the attach files? thanks

0 votes
Matteo Cominetti October 22, 2013

Hey maybe I was not clear, I do autenthicate, that's how I get the attachment url: https://developer.atlassian.com/static/rest/jira/6.0.1.html#id150787

But then, as I use the attachment url, let's say of a picture, inside a picture box it won't show because it's like an anonymous user trying to see the file, for the server since the url is jira/secure/....

What do you mean by streaming?

0 votes
Timothy
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.
October 22, 2013

because the "user" (my app) is not logged in

Then you need to log yourself in. There's oAuth and basic auth.

or a way to bypass autenthication for attachments?

Create a user that has permission to all issues? And I don't think there's a way to just bypass that.

Have you tried streaming the attachment using the content attribute?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events