I am creating pages automatically (programmatically), and in my pages I have file (attachment) preview macros which are pointing to attachments that I upload (also programmatically) after my page is created. When I open a page, to check what has been created, everything works fine, file previews are presenting attachments correctly. But if I manually edit (click on pen) the page, without touching macros, all file preview macros start showing "Failed to load". And when I check the page content through API for file preview macro it is returning:
<ri:attachment ri:filename=\"UNKNOWN_ATTACHMENT\" ri:version-at-save=\"1\" /> .
Steps:
1. Create page with content including file (attachment) preview macros through API
2. Upload attachments through API
3. Try to edit page manually in Confluence
4. While and after editing the page file (attachment) preview macros start showing "Failed to load"
Conclusion:
File (attachment) preview macros only work if I do not manually edit page in Confluence.
Jinja2 template for file preview macro:
<p class="media-group">
<ac:structured-macro ac:name="view-file" ac:schema-version="1">
<ac:parameter ac:name="name">
<ri:attachment ri:filename="{{attachment}}" />
</ac:parameter>
</ac:structured-macro>
</p>