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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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.

1 answer

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

83 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you