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)
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I saw something about a session token? are you using anything similar in this request that I can't see?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.