How to download a file with only the media ID?

Hello,

I want to copy paste the description of an issue into another ticket system in my company. That includes screenshots in the description.
The ADF format returns the following object if there are screenshots in the text:

"description": {
            "type": "doc",
            "version": 1,
            "content": [
                {
                    "type": "paragraph",
                    "content": [
                        {
                            "type": "text",
                            "text": "this is a test "
                        }
                    ]
                },
                {
                    "type": "mediaSingle",
                    "attrs": {
                        "layout": "align-start"
                    },
                    "content": [
                        {
                            "type": "media",
                            "attrs": {
                                "type": "file",
                                "id": "76481dc1-acca-4e90-be7b-096124d1e54d",
                                "collection": ""
                            }
                        }
                    ]
                }
            ]
        },

In the documentation of the document format, Atlassian states:

  • id is the Media Services ID and is used for querying the media services API to retrieve metadata, such as, filename. Consumers of the document should always fetch fresh metadata using the Media API.

However, there is nothing to be found about this “Media API”.
Can someone tell me if there is a way to download an image with only the Media ID?

I had the same problem. The media API is an internal atlassian api and there is no simple way to convert mediaId to attachmentId.

It is possible solution:

Open the console network in issue view and you will see POST request to https://api.media.atlassian.com/items, the request body contains mediaId list but the response contains the list with detailed information, you can take the detailed information and then take issue attachments field info and match the data by file size and filename to detect the attachmentId, then you can build download URL using attachmentId

1 Like

Looks really promising! I’m out of the office for the next two days, so I will try this next week at the earliest, but thank you very much for the input!

I will keep this topic up to date and mark your answer as a solution after I tested it.

@Alexandr, how did you authenticate the request? The POST request needs a bearer token.

Is that supposed to be a JWT token?

Just copy paste it from the console headers