How to get filename from media node id

RC
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!
March 31, 2019

Hi, 

I would like to ask you, how can I get filename or attachement id linked on document node media https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/media/

Documentation says, that from attrs.id I can get eg. filename, but its not written how, on which endpoint or whatever...

I spend almost an hour to find how to get this, but I found nothing.

Thanks anyone who will give me the answer.

2 answers

1 vote
Milánovics Péter
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!
December 13, 2022
1 vote
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 2, 2019

Hi Rostislav,

All attachments in Jira are always bound to a specific issue in Jira.  As such, we can find both the id and the filename of the attachments by doing a GET to the /rest/api/3/issue/{issueIdOrKey} endpoint and passing it the issuekey or the issue id number where that attachment is bound to.   So for example, if my issuekey is SCRUM-123, and I know it has an image attached to that issue, I can do a REST call of

GET /rest/api/3/issue/SCRUM-123

and I'll get back something like this:

    "attachment": [
      {
        "id": 10000,
        "self": "https://your-domain.atlassian.net/rest/api/3/attachments/10000",
        "filename": "picture.jpg",
        "author": {
          "self": "http://your-domain.atlassian.net/rest/api/3/user?accountId=99:27935d01-92a7-4687-8272-a9b8d3b2ae2e",
          "key": "mia",
          "accountId": "99:27935d01-92a7-4687-8272-a9b8d3b2ae2e",
          "name": "mia",
          "avatarUrls": {
            "48x48": "http://your-domain.atlassian.net/secure/useravatar?size=large&ownerId=mia",
            "24x24": "http://your-domain.atlassian.net/secure/useravatar?size=small&ownerId=mia",
            "16x16": "http://your-domain.atlassian.net/secure/useravatar?size=xsmall&ownerId=mia",
            "32x32": "http://your-domain.atlassian.net/secure/useravatar?size=medium&ownerId=mia"
          },
          "displayName": "Mia Krystof",
          "active": false
        },
        "created": "2019-04-01T14:51:03.159+0000",
        "size": 23123,
        "mimeType": "image/jpeg",
        "content": "https://your-domain.atlassian.net/jira/attachments/10000",
        "thumbnail": "https://your-domain.atlassian.net/jira/secure/thumbnail/10000"
      }
    ],

Along with a lot more json data.  But this section will tell us what attachments a Jira issue has, the attachment ids, and the attachment filenames.

I hope this helps.

Andy

Emmanuel Wang
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!
June 23, 2021

we also met the issue, after we migrated projects from server instance to cloud instance, we sync the attachments to cloud project,  the attachment displayed in description and comments are failed, after checking with api, we found the good attachments in comment have a  "occurrenceKey" key , but how to find the right occurrenceKey key for the attachment? we don't know that.

Michael Cowan January 9, 2022

One issue is that the ID in the API does not match the media id returned from the ADF media node? The media id is a GUID while the api returns an int? 

{ "type": "media", "attrs": { "type" : "file", "id": "6e7c7f2c-dd7a-499c-bceb-6f32bfbf30b5", "collection" : "my project files" } }

Here is the problem I need to solve,

1) I have an issue with 10 inline images

2) Looping through the ADF I can find the media nodes easily .. but there is nothing that lets me connect the mediaNode to the image.  Yes it renders in Jira correctly, but I need to output a report using the API and I can not figure out which image goes where?

Like # people like this
Prakash Natarajan April 11, 2024

@Michael Cowansame issue. Did you happen to find a way to get this image?

Suggest an answer

Log in or Sign up to answer