Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

Rest V2 API returns wrong ID for attachment

Daniel Wendler February 10, 2025

The Atlassian API is returning data like this from the wiki endpoint `/wiki/api/v2/pages/<id>`

{"type":"media","attrs":{"width":1278,"alt":"alt text","id":"51013016-44a8-438f-b0b7-fb619714df9a","collection":"contentId-1180220222","type":"file","height":1500}},

The ID is not requestable from the endpoint `/wiki/api/v2/attachments/<id>`, the format is not UUID but pattern (att)?[0-8]+

See https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-attachment/#api-attachments-id-get

 

How do I cirumvent this mapping issue?


How do I request the media attachments via the ID in UUIDv4 formt?

 

There is already an issue up here that mine duplicates, without an answer.

This is very related to the following issue from 2022, but there are only workarounds no solutions..

 

 

1 answer

1 accepted

0 votes
Answer accepted
Daniel Wendler February 18, 2025

Getting the `AttachmentSingle` API response object

The endpoint `/wiki/api/v2/attachments/{id}` is broken and doesn't return data, no matter if we use UUIDv4, prefixed, or non-prefixed content-ID.

Instead, I'm using the endpoint `/wiki/api/v2/attachments`, with parameters `limit` => `1` and `filename` => `.attrs.alt`.

The `.downloadLink` property in the resulting ADF works and could also be built manually:

Use the fields `.attrs.alt` as `$filename`, and from the field `.attrs.collection`, strip the prefix (`([a-zA-Z]+-)`) as `$contentId`:

    https://<atlassian-host>/wiki/download/attachments/{$contentId}/{$filename}

Suggest an answer

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

Atlassian Community Events