I used Get page by ID to retrieve a page and then Create Page to create a new one by copying the previous page.
However, all the attached images show the following error message:
"Something went wrong. We couldn't generate a preview for this file. The selected item was not found on the list."
Why is this happening, and how can I fix it?
Hi @김현석_포카_ ,
The GET /pages/{id} retrieves the page body (with image references), but the POST /pages only creates the new page with those references intact. Attachments (like images) aren't automatically copied; they stay attached to the original page, so references break on the new one.
You can copy the attachments separately and use the v1 REST API for attachments (v2 doesn't support uploads yet so you should stick to v1 for this). If your body uses standard image macros (e.g., !image.png!), uploading with the same filename should auto-resolve previews without body updates. :)
I hope everything works out for you!
Best,
Peter
Thank you for the helpful solution.
I have one more question — is there a way to retrieve all attachments used within a page?
From what I can see in the v1 API, there’s only an endpoint to get the URI to download an attachment, but not one that lists all attachments used in the page body.
Is there an API method or recommended way to get them all?
Poka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @김현석_포카_ ,
Unfortunately, there's no direct endpoint to list only "used" attachments, but you can combine APIs to achieve it:
Fetch the page body to parse references -> then list all child attachments and filter matches. The v1 endpoint you mentioned is for downloading, but for listing, use /rest/api/content/{id}/child/attachment (v1):
Step 1: List All Attachments on the Page
- Use GET /wiki/rest/api/content/{id}/child/attachment (Use v1)
- Query params: ?expand=metadata.mediaType,version (for details).
- You can refer to the below cURL (adjust with your params):
curl -u 'email:api_token' \
https://your-site.atlassian.net/wiki/rest/api/content/{pageId}/child/attachment?expand=metadata.mediaType,version
-> Returns array of attachments with ID, filename, download link...
Step 2: Identify Used Attachments (Parse Body)
- GET the page with body.storage expanded:
- v1: v1 /rest/api/content/{id}?expand=body.storage
- v2: /wiki/api/v2/pages/{id}?expand=body.storage
- Parse the body.value for <ri:attachment ri:filename="yourimage.png" /> tags. These reference used attachments by filename (or ri:attachmentId for IDs).
- Cross-reference filenames/IDs with Step 1's list to filter "used" ones.
If parsing is manual (e.g., in script), use regex like <ri:attachment ri:filename="([^"]+)" to extract filenames. For automation, tools like Python BeautifulSoup work well.
You can refer to the below links:
Best,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much!
I followed your instructions, and everything is now displaying correctly.
I really hope the v2 API adds support for retrieving and uploading attachments soon — that would make things much easier.
Thanks again for your help!
Best,
Poka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@김현석_포카_ as the maker of a Confluence Attachment Manager I can say that Atlassian has deprecated some APIs recently that have impacted the ability to filter by unused. Which is what @Peter_DevSamurai is trying to help you with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the context!
Everything’s working well now — I was able to resolve the issue thanks to @Peter_DevSamurai 's detailed explanation.
Really appreciate both of you taking the time to help out!
Best,
Poka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@김현석_포카_ happy to learn that @Peter_DevSamurai suggestion worked. Atlassian I suspect didn't realize the degree of the problem the API deprecation caused in this area, if did would have built more equivalences. But APIs have to change to improve, some trade-off required to move forward.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, and for those who are not familiar or tech-based, you can check out the Confluence Attachment Manager plugin to resolve this quickly as well!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.