Forums

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

What authentication method is required to download attachment URLs?

Maverick Embry September 20, 2021

Hello,

 

I have managed to get the attachment content URL from "/rest/api/2/search". I then do a GET request on this content URL which in return gives me the encoding of the file. In this process, I had to use basic authentication (without API key) in order to receive a response from the content URL. 

As of 2019, Jira tells us that basic authentication is deprecated:

 https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/#which-apis-and-methods-will-be-restricted-

After reading the above article, how are we supposed to authenticate into the GET request against the content URL? I've only had success by using basic authentication (assuming because it's an interactive login so I can download attachments)

1 answer

0 votes
Ajay _view26_
Community Champion
September 20, 2021

Hi @Maverick Embry 

basic authentication has been replaced by "API token" to authenticate REST APIs

You can follow the documentation link

Your GET request would be similar to this - 

curl -D- \ -X GET \ -H "Authorization: Basic ZnJlZDpmcmVk" \ -H "Content-Type: application/json" \ "https://your-domain.atlassian.net/rest/api/2/search/QA-31

 

Cheers

Ajay

Maverick Embry September 21, 2021

Hello @Ajay _view26_ 

Thanks for the response. So, I am using an API token to authenticate my other requests, but for some reason when I try to do a GET request on the content URL within the attachment data, I get a 401 code. BUT If I use basic auth user/pass it WORKS.  

I'm just confused as to what is the right way to authenticate for getting the attachment data. Because the only method that works.. is deprecated

Maverick Embry September 21, 2021

Or is my approach to getting the data wrong? Here's my process:

- GET issues
- Parse out attachment data from issue (this gives me a URL for an attachment on the issue)

- do a GET on the content URL (link to attachment) -- This gives me the encoding of the file which I use in my other system. If I use API token here, it fails. If I use basic auth here it works

Ajay _view26_
Community Champion
September 21, 2021

Hi @Maverick Embry 

I tried out setting the basic auth with ( user name as my email & password as the API token) and got a success in getting the attachment. 

Example below Screenshot 2021-09-22 074949.jpg

Maverick Embry September 22, 2021

I saw something about a session token? are you using anything similar in this request that I can't see?

Suggest an answer

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

Atlassian Community Events