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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,482
Community Members
 
Community Events
184
Community Groups

Can jira API return the URL of an image in attachments ?

Edited

I want to use curl to download the images I have on an issue (as attachments).  The problem is the API doesn't return the URL that leads to these images. 

"content" : "https://INSERTCOMPANY.atlassian.net/secure/attachment/10013/image-20201217-080137.png"

The content field URL returned by the API is not what I'm looking for. When entered in the browser this url downloads the correct image, but since it doesn't actually point towards the image I can't use the curl function on it.

2 answers

0 votes
Quoc Duan Thoi Ngoc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 10, 2023 • edited

Try use this: https://xxxxx.atlassian.net/rest/api/2/attachment/{attachment_id}

The attachment id can get from this:

https://xxxxx.atlassian.net/rest/api/latest/issue/{issue_id}

 

the above image url actually not a direct one to the image, but redirect with some additional validate behind the sence

0 votes
Prince Nyeche
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.
Jan 11, 2021

Hi @Liviu Florea 

Welcome to Community! You will need to parse the url in the API to get the right link for you to be able to download attachments.

Hi, 
I'm afraid I'm a bit lost. Can you elaborate on your last answer, maybe provide an example ?

Prince Nyeche
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.
Jan 14, 2021 • edited

Hi @Liviu Florea 

What endpoint did you use? I would use the GET Issue endpoint if I want to get the full url for an attachment  from an issue then output the result. I can show an example but it's in python would that be preferable?

I have tried using the GET issue and GET attachments endpoints so far. I would appreciate seeing the python example.

Prince Nyeche
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.
Jan 14, 2021

Hi @Liviu Florea 

I actually have a library where i'm trying to make extracting data from Jira Cloud easier via REST API. Here's an example code to extract attachment information using python and searching with JQL. You can see how I implemented the method here on Github on line 265.


from jiraone import LOGIN, PROJECT

user = "email"
password = "token"
link = "https://yourinstance.atlassian.net"
LOGIN(user=user, password=password, url=link)


if __name__ == '__main__':
# the output of the file would be absolute to the directory where this python file is being executed from
# you can use any valid jql query
jql = "project%20in%20(COM%2C%20PYT)%20order%20by%20created%20DESC"
PROJECT.get_attachments_on_projects(query=jql)

Like Quoc Duan Thoi Ngoc likes this

Hi,

Please let me reply here as I am also having the same issue.

@Prince Nyeche  , I tried the above code of jiraone.

However, the "attachment_file.csv" is created with header only. There is no data inside.  there is no other response in the debugger also.

what could be a problem here? Did I miss anything?

Prince Nyeche
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.
Jun 17, 2021

Do you have access to the project or are you able to view the project issues? Let me know what type of errors or output you're getting?

@Prince Nyeche  Thanks for your response.

Yes I have access to the project and am able to view the project issues also.

when I run PROJECT.get_attachments_on_projects(query=jql) in Debug Console, below message appear.

There was no error in Terminal and no response.

debug error.JPG

Prince Nyeche
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.
Jun 17, 2021

It seems this is caused by another dependency that I'm not familiar with. Please can you confirm that the above request is done with the example given in the above post?

Yes, it's the same code. Please see the below screenshot.

I am trying to transfer attachments from bluecom to slsbearings. 

Manually importing CSV doesn't show the attachment files. then, I tried this code.

python code sample.JPG

Prince Nyeche
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.
Jun 18, 2021

Hi @susu_san 

I think on your device there might be something wrong with the Threading, I'm not so sure what it is based on the response you showed. So I think a better way for you to do this is to use this script instead. It has a config.ini file which you will need to add your login credentials there. Since this is a cloud-to-cloud transfer, add the same credential for the source and target section. Then add your JQL query on the script on line 36 as mentioned on the README file.

Suggest an answer

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

Atlassian Community Events