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,644,339
Community Members
 
Community Events
196
Community Groups

Trying to fetch attachment using REST API from JIRA is not working

I am trying to fetch attachment from JIRA using REST API(provide by Jira). But I am not getting the metadeta of attachment and it is giving me only a URL which is also secured. can anyone please help how to get attachment from Jira using REST API?

3 answers

It looks like this endpoint returns the binary now.
But I have no idea how to convert it into base64
Any idea how to do that?

@Angélica Luz Could you please help with this?

Atlassian introduced an experimental endpoint to read attachments.

GET /rest/api/3/attachment/content/{id}

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-attachment-content-id-get

0 votes
Angélica Luz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 11, 2020

Hello @RishabhT,

Thank you for reaching out to Atlassian Community!

Just to make sure we are on the same page, I would like to confirm if you are using the API mentioned on the documentation below:

curl --request GET \
  --url 'https://your-domain.atlassian.com/rest/api/3/attachment/{id}' \
  --user 'email@example.com:' \
  --header 'Accept: application/json'

If that's the case, I tested here and it shows the correct response. 

Would mind sharing with us a screenshot of the response you receive?

Regards,
Angélica

Hi Angelich,

Jira does not provide directly the content of the attachment but the secure URLs of the attachments.

Here my colleague @RishabhT  is concerned with the contents of the attachment.

The createmeta request working fine but returning only URLs perhaps we need file actual content in the form of base64/blob of the attachment.

 

So, Is there a way to fetch the content of the attachment ?

 

We are getting following response currently.

attachment response.png

Angélica Luz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 15, 2020

Hello @Merajul Hasan,

Thank you for the details.

I'm afraid this is not possible using API. Blob is recorded in the database which can't be accessed in Jira Cloud. 

The only APIs available are the ones from the documentation and none of them returns what you need.

Also, I didn't find any feature request suggesting this ability, so please, feel free to raise one on jira.atlassian.com (project JRACLOUD) adding more details about why this feature is important for your environment.

Regards,
Angélica

Hi @Angélica Luz 

Is it still not possible? 

I am also looking for the same, using content URI, I would like to get contents so we can insert that attachment in our system. 

@RishabhT and @Merajul Hasan  Did you find the solution or workaround? Please share. 

Unfortunately, there is no solution , u cud not get the content of attachment

Angélica Luz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 08, 2021

Hi @Suraj Rajoria,

Thanks for reaching out to Community!

It's still not possible to get the content of an attachment.

As mentioned in my previous reply, Blob is recorded in the database which can't be accessed in Jira Cloud since it's a restricted function.

Kind regards,
Angélica

Mohammed Talha Toufeeq
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!
Jul 21, 2023 • edited

Hi @Suraj Rajoria

I've found a solution using the atlassian-python-api,

Create an instance on the backend using your username and api key,

I've done it through a FastApi backend on python.

The attachment URLs need to be hit from a seperate route, fetched through sessions looped through in this way:

Here is my route:

@router.get('/v1/jira-get-attachment', status_code=http.HTTPStatus.OK)
async def get_issue_attachment(issue_key: str):
try:
data = jira_ticket_service.get_attachment(issue_key)
response = SuccessResponse(
"URL found", {"data": data}
)
return JSONResponse(content=jsonable_encoder(response.dict()))

Here's the function:

 

def get_attachment(issue_key: str):
issues = jira.get_issue(issue_key)
attachments = issues.get("fields").get("attachment")
urls = []
for attachment in attachments:
content_url = attachment.get("content")
session = jira.session
response = session.get(url=content_url)
urls.append(response.url)
return urls




Suggest an answer

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

Atlassian Community Events