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,463,733
Community Members
 
Community Events
176
Community Groups

How to get filename from media node id

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
Andy Heinzer Atlassian Team Apr 02, 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

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.

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events