I am trying to download attachment of issue through code using Attachment Content URL.
But for some file names having Special Characters like '(',')' or chinese Literals like '機能', I get 401 unauthorized message.
Let me know if there is some way through which we can get attachment content.
Hello @Asif Diwan ,
Welcome to the Atlassian Community.
From information provided so far I understand that:
Can you kindly confirm my understanding is correct?
In case it is, can you check if this works using Curl?
Please see below example for details on how to do so. Also, make sure to remove the sensitive data as I did below and paste the results in your reply:
curl -D- -L -u EMAIL:API-TOKEN -H "Accept: application/json" https://HOSTNAME/secure/attachment/10000/ycBsQT7.jpg -o file.jpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
HTTP/2 302
server: AtlassianProxy/1.15.8.1
cache-control: no-cache, no-store, must-revalidate
content-type: image/jpeg
strict-transport-security: max-age=315360000; includeSubDomains; preload
date: Wed, 25 Sep 2019 14:45:19 GMT
atl-traceid: babfca7aab34c384
[REMOVED SENSITIVE CONTENT]
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
HTTP/2 200
date: Wed, 25 Sep 2019 14:45:20 GMT
content-type: image/jpeg
content-length: 34498
[REMOVED]
content-disposition: inline; filename="ycBsQT7.jpg"
cache-control: private
x-envoy-upstream-service-time: 244
strict-transport-security: max-age=31536000; preload
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
server: globaledge-envoy
100 34498 100 34498 0 0 31591 0 0:00:01 0:00:01 --:--:-- 31591
In case my understanding is not correct. Please provide more details.
Cheers,
Dario
Hi @Dario B ,
Thanks for your reply.
I have an addon and using addon key we are trying to get attachment using rest api end point.
So far I was successful in getting all attachments using this rest api end point.
But for file having special characters in its name I get 401 unauthorized request error.
Thanks,
Asif
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply @Asif Diwan ,
I will try to reproduce the issue having a file name with a comma, also if there are chances that this is failing since the comma can be seen as a delimiter, like explained also in:
For the rest, could you kindly provide more details on what is the 機能 character and what other characters are known to causing this issue?
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Asif Diwan ,
I cannot reproduce the issue. Attaching an image having a comma in the filename to a Jira issue and then downloading it using REST API works fine on my side (I use Linux). Please see below for more details:
File name: cannot-quote,list.png
Getting attachment content url:
"content": "https://NAME.atlassian.net/secure/attachment/10005/cannot-quote%2Clist.png",
"thumbnail": "https://NAME.atlassian.net/secure/thumbnail/10005/cannot-quote%2Clist.png"
Downloading the file:
curl -D- -L -u EMAIL:API-TOKEN -H "Accept: application/json" https://NAME.atlassian.net/secure/attachment/10005/cannot-quote%2Clist.png -o image.png
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 HTTP/2 302
server: AtlassianProxy/1.15.8.1
cache-control: no-cache, no-store, must-revalidate
content-type: image/png
[REMOVED SENSITIVE CONTENT]
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 HTTP/2 200
date: Fri, 04 Oct 2019 16:33:28 GMT
content-type: image/png
content-length: 37963
[REMOVED]
content-disposition: attachment; filename="cannot-quote,list.png"
[...]
100 37963 100 37963 0 0 30129 0 0:00:01 0:00:01 --:--:-- 72448
Now, if this still does not work for you, can you kindly let me know which Operating System you are using and how you are downloading the attachment?
Also, can you kindly perform the same test I did above using Curl and copy paste the results (removing sensitive data) into your answer?
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't use CURL @Dario B
Instead use Jira Rest API to get attachment.
Use Addon Key for authentication. As an addon developer I don't have client's credentials. So I have to use Addon User and Key details for authentication.
Let me know if you need more details.
Thanks,
Asif
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Asif Diwan ,
Please notice that Curl is just one of the many software available that you can use in order to send a REST API request to a given endpoint.
Being curl a text only software, I asked to use it to try to reproduce the issue so that it would be possible to easily paste the results of the test in here.
This is because I already tried reproducing the issue by attaching a file with a comma in the name but everything worked fine for me (the curl output is available in my previous post).
Therefore, I need you to run the same test so that we can try narrow down the issue:
Also, please notice that I only tried to reproduce the issue by attaching a file having a comma in the name. As already mentioned:
could you kindly provide more details on what is the 機能 character and what other characters are known to causing this issue?
Finally, for the future, please notice that this is not the best place to get help on development related questions. The right resources are listed in https://developer.atlassian.com/resources.
Specifically:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just in case anyone else runs into this, for commas at least, in the "content" field of an attachment, they will be uri encoded so %2c instead of , so when you send the download request to Jira with the %2c still there, it can't find that attachment.
My solution using Node.js was to run the content urls through decodeURIComponent before making the request for download.
Matt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.